Adding the Call Button3:57 with Heath Hodgert
In this video, we'll go back into our iOS storyboard and add a call button. At the end of this video we'll have an app that calculates all our pizza needs.
Now that we have our UI alert controller, and a button for 0:00 Ok, we'll need to show it on the view controller. 0:05 The iOS method to present a controller Is the PresentViewController. 0:13 It takes a view controller, 0:21 And default values. 0:31 Now we need to go to the ViewController. 0:46 Create a new dialer. 0:53 You can pass in this because this is a view controller. 1:01 And then pass the dialer into the PizzaCalculatorService. 1:06 The mistake I've made here is I did not implement the interface. 1:12 Now the PizzaCalculatorService is happy. 1:31 So we now have our updated calculator service. 1:34 We'll also need to go back to the storyboard and add a call button. 1:37 And add a delegate to handle the touch up inside event. 1:41 So open the main story board, Use the toolbox to add a button. 1:45 Make it larger, and 2:06 constrain it under the label. 2:09 Left and right. 2:16 Then let's give it a name of CallButton. 2:20 Change the title to Call. 2:29 Now let's go back over to the ViewController, And 2:36 add another handler for the CallButton. 2:41 We simply need to call the PizzaCacluatorService and 2:55 the CallPizzaParlor. 2:59 And that's it, so now we can run our app and make a call. 3:04 Now we can enter a number of people, calculate. 3:13 We see our new text, and we can call. 3:17 But since we're in an emulator, we can't actually make the call. 3:21 So we added a message to show that it was working. 3:25 We can stop the debugger and move on to the next section. 3:29 This was a simple example of sharing code. 3:33 The benefit on this small of a scale 3:37 may make you wonder if it's really worth the effort. 3:40 But imagine, a medium or 3:44 large scale mobile app project that needs to support multiple mobile platforms. 3:45 Having a way to share business logic across platforms is a major win. 3:52
You need to sign up for Treehouse in order to download course files.Sign up