Using Barcode drawer for iPhone Control to generate, create UPC - 13 image in iPhone applications.

www.OnBarcode.com

Set the background color of the UIView them hidden) and one UILabel, set against an aluminum-colored background to an attractive aluminum color. You do on the iPhone, complete the object this on the Attributes tab of the inspec- creation you need for your eventreporter tor window, as you do most of your work project. in this project. Create a UILabel, stretch it across the bottom of the screen, and set the color to be steel. Also, clear its text so it doesn t display anything at startup. Create two UITextFields. This class of objects is generally used to accept input, but we opted to use the objects for pure display purposes because we like their look. (Don t worry; we ll show how to use the full functionality of a UITextField toward the end of this chapter.) Place each UITextField at the center of the screen using Interface Builder s handy positioning icons. Set this location s coordinates to 159, 230; and set its origin to middle.

Using Barcode encoder for iPhone Control to generate, create GS1 - 8 image in iPhone applications.

www.OnBarcode.com

For each UITextField, input text that lists its starting position; this will later be updated by the program as the text field moves. Deselect the user interaction enabled option for each UITextField so that users can t manipulate them. The process takes longer to explain than it takes to accomplish. You ll have a working interface in a couple of minutes.

Using Barcode maker for Eclipse BIRT Control to generate, create EAN 13 image in BIRT applications.

www.OnBarcode.com

Because you ll modify all three of these objects during the course of your program s runtime, you need to link them to variables inside Xcode. You should link everything to your controller, because it takes care of updates, as is appropriate under the MVC model. The tricky thing here is that the view controller doesn t seem to appear in your eventreporterViewController.xib file at least not by that name. Fortunately, there s a proxy for it. Because the view controller is what loads up the .xib, it appears as the file s owner in the nib document window. You can therefore connect objects to the view controller by linking them to the file s owner proxy. This is a common situation, because view controllers frequently load additional .xib files for you. The following is your view controller s header file, eventreportViewController.h, following the addition of these IBOutlets. The code also contains a declaration of a method that you ll use later in this project:

Using Barcode generation for Android Control to generate, create USS Code 39 image in Android applications.

www.OnBarcode.com

Touch events can be captured only by UIView objects. Unfortunately, as of this writing, there s no way to automatically delegate those touches to a view controller. Therefore, in order to manage touch events using the MVC model, you typically need to subclass a UIView, capture the events there, and then send mesUIWindow sages to the view controller. In this project, you create a new object class, UIViewController reportView, which is a subclass of UIView. You then link reportView that new class into the view controller s existing view through Interface Builder. Open eventreporterView- UITextField UILabel UITextField Controller.xib, go to the Identity tab for the view object you ve been using, and change its name from UIView to Figure 6.4 Working primarily reportView, as you did in chapter 5 when you created a in Interface Builder, you connect six objects that you ll table view controller subview. use to report events.

Download from Wow! eBook <www.wowebook.com>

Monitoring events and actions

Any new methods you write into reportView, including methods that capture touch events, will be now reflected in your view. To clarify this setup, figure 6.4 shows the view hierarchy that you ve built for your eventreporter project. With a brand-new UIView subclass in hand, you can now write methods into it to capture touch events and forward them to its controller. This code, which appears in reportView.m, is as follows:

This code is pretty simple. You re filling in standard methods so that your program will have the responses you want when those messages are sent. The overall structure of these methods reminds us of several important facts about events. First, as promised, there are a variety of responder methods. Each of them reports only the events for its specific phase. So, for example, the touchesBegan:withEvent: method only has UITouchPhaseBegan touches in it. In forwarding these touches, you could keep the different phases distinct, but instead you throw everything together and sort it out on the other side. Second, we ll comment one final time that these methods send you two pieces of information: a set of touches and an event. They re partially redundant, and which one you work with will probably depend on the work you re doing. If you re not doing complex multitouch events, then the NSSet of touches will probably be sufficient. Third, note that you re sending An aside on the text fields and label the touches to the view controller If you were to code in this example, you d disby way of the nextResponder cover that the program correctly responds to method. As you ll recall, the touch events even when the touches occur responder chain is the opposite of atop one of the text fields or the label at the the view hierarchy at its lower levbottom of the page. How does the program manage that when you built event response els, which means in this case the into only the reportView nextResponder of reportView is the UIViewController. We would The answer is this: it uses the responder have preferred to have the UIViewchain. The text fields and the label don t respond to the event methods themselves. As Controller naturally respond to a result, the events are passed up the rethe touches messages, but we sponder chain to the reportView, which does made use of the responder chain leap on those events, using the code you ve in the next best way. As of this just seen. writing, the compiler warns that