Your First iOS App - Part 3: Buttons and | Ray Wenderlich Videos

Learn how to add a button to the app and connect it to some Swift code that prints a message to the console.

This is a companion discussion topic for the original entry at

We are creating a app in landscape mode, but we weren’t told how to change the view in the simulator. The orientation is by default in portrait mode. To change this when the simulator is open, go to to Hardware>Panel>Orientation> Landscape Right to change the orientation.

An easy way to quickly change orientation is by typing CMD + Left or CMD + Right while the simulator is open.

How to add the handy object select button in the XCode toolbar that showed in the video 4:23 (the button that just beside the “Show Standard Editor” button)?

@wwj That should be there by default if you use Xcode 10 (it’s a new feature). Do you have that installed?

I am using Xcode 10. However, just like the previous observations(comments) Even after the orientation selected( landscape), when running the simulator the “hit me” button isn’t centered and it’s on portrait view. However, after using CMD right or CMD left, I was able to correct the simulator view.

@fullpopfreddy Do you still have issues with this?


I’m trying to do the first step of adding @IBAction func but I keep getting an message that states “Expected identifier in function declaration” and doesn’t show the showalert in the sentevents.

@csbal90 Do you still have this issue?

I am at the part where you link the button to the function, but when I drag it, showAlert does not show.

@readreid What errors do you get exactly?