![]() Please change Type back to UIButton, then enter buttonTapped for the name, and click Connect. You'll still get asked for a name, but now you'll see an Event field, and the Type field has changed from UIButton to Any. When you choose Action rather than Outlet, the popup changes a little. If you choose Outlet here (which I do all too often because I'm in a rush), you'll cause problems for yourself! That's right: where it says "Connection: Outlet" at the top of the popup, I want you to change that to be “Action”. If you're doing it correctly, you should see a tooltip saying, "Insert Outlet, Action, or Outlet Collection." When you let go, you'll see the same popup you normally see when creating outlets, but here's the catch: don't choose outlet. Select the first button, then Ctrl+drag from it down to the space in your code immediately after the end of the askQuestion() method. ![]() In my haste I screw this up all the time, and I don't want it to confuse you! Warning: please read the following text very carefully. ![]() So, select Main.storyboard, then change to the assistant editor so you can see the code alongside the layout. Isn't it amazing ?!, problem solved ! and I hope this article helps someone too.I said we'd return to Interface Builder, and now the time has come: we're going to connect the "tap" action of our UIButtons to some code. The resulting outcome of the object(Button) position when tested with other device screen size remain the same. Testing the resulting outcome using different device size: To get the horizontal mid-position of the screen using the x-position, one have to twerk and play around with the amount multiplied by 30 and as well use the device simulator horizontal mid-point line to view if the object(Button) is placed at your desired mid-point or position on the device screen or simulator. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |