开发者

iPhone Beginner Question - Hooking Up Actions

I'm just starting out with iPhone development, and in my hello world application I'm having a hard time hooking up a view to a controller with actions. I followed the instructions in the book I'm reading (I believe), but depending on where I run the application the app behaves differently.

-When i command-r from the code, I see only the single button I have on the view tak开发者_运维百科ing up the whole window. When I click the button the action is triggered.

-when I command-r from the interface designer I see the button, label, and textbox lined up correctly. When I click the button nothing happens.

Anyone know why this is happening/how to fix it? Thanks.


Launching simulator from interface builder only simulates selected .xib file. You should only do that to test your view design.

If you want to learn the basics about iPhone development I recommend:

NewBoston: http://www.thenewboston.com/?cat=34&pOpen=tutorial

Stanford: http://itunes.stanford.edu/

both are free video tutorials on how to make iPhone apps.

Good luck!


you accidentally the whole view.
Seriously. You made one wrong connection. You connected the view outlet of the viewController (aka File's Owner) with the UIButton.

iPhone Beginner Question - Hooking Up Actions

just delete this connection and connect the view outlet of the File Owner with the "Root"View.

iPhone Beginner Question - Hooking Up Actions

And you should probably remove almost all connections that trigger btnClicked: too. TouchUpInside from the button is enough.

And you should follow the objective-c coding style (Part II) and start all Class names with a capital letter. chapter_2ViewController should be something like Chapter2ViewController.


To my knowledge you cannot run an app from interface builder, I may be mistaken.

You should make sure your interface builder file is saved and run the app from within xcode


just a guess, but is the window size in the simulator different than that in IB? You might check the control resizing masks and on the sizing tab in IB.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜