Tab Bars and Pickers

(Pickerview) or just a picker are the controls with the dials that spin. Pickers are more complex than other iPhone controls.Pickers can be configured to display one dial or many, by default pickers display text, but many can also be made to display images. Date picker is the easiest type of picker to implement.Picker has very few attributes that can be configured from within the interface builder. Date picker is the only one that can be  grabbed from the interface builder.  A picker needs to be provided with both a picker delegate and a picker data source. The picker defers several jobs to its delegate. The most important of these is the task of determining what to actually draw for each of the rows in each of its components.The picker asks the delegate for either a string or a view that will be drawn at a given spot or a given component. The picker gets its data from the delegate. In additon to the delegate, a data source is required.  The data source tells the picker how many components it will be working with and how many rows make up each component.Its very common for the data source and the delegate to be the same object and just as common for that object to be the view controller for the picker’s endorsing view.The data source isn’t actually an object designed to hold data.Root controller to manage swapping of applications other views. Tab bars use icons to represent each of the tabs. 24 x 24 pixel .png pics need to be added to the resources folder. The root controller controls...

Multiview Applications

Real Power of iPhone platform emerges when you can switch out views based on user input. Simplest example of a multiview application is a utility app. A utility view focusses primarily on a single view but offers a second view that can be used to provide more detail than the primary view. Several tab bar apps that ship with the iPhone. A tab bar is used for selecting one and only one option from among two or more. A toolbar can hold buttons and certain other controls, but those items are not mutually exclusive. Nearly all multiview applications use the same basic pattern. The nib file is a key player. The root controller is the primary view controller for the application and as such is the view that specifies whether it is ok to automatically rotate to a new orientation, though the root controller can pass responsibility for things like that to the current active controller. In multiview apps most of the screen will be taken up by a content view and each content view will have its own controller with its own outlets and actions. In a tab bar application, for example tapping on the tab bar will go to the tab bar controller, but taps anywhere else on the screen will go to the controller that corresponds to the content view currently being displayed. Each content view generally consists of up to three pieces: the view controller, the nib and a subclass of UIView.Content view will always usually have an associated view controller, will usually have a nib and will sometimes have a subclass UIView. One of...

Autorotation and Autoresizing

Auto rotation might not be right for every application. Several apps support only a single orientation rotation.If auto rotation enhances user experience add it to your app. Auto rotation is specified in the view controller. Most of the work in actually moving the pixels around the screen is managed by the iPhone OS. There are three approaches to auto rotation dependent upon the complexity of the interface. With simpler interfaces simply specify the auto resize attributes for all the objects that make up the interface.More complex interfaces have to handle auto rotation in a different manner. One approach is to manually reposition the objects in the view when notified that the view is rotating. The second approach is to actually design two different versions of the view in the interface builder, one for portrait mode and a seperate one for landscape mode. In both cases need to override methods from UIViewController in view’s controller class. Add code to .m file, method already provided (commented out) called shouldAutoRotateToInterface need to uncomment and add code.Four defined orientations in the way that the phone is held: UIInterfaceOrientationPortrait UIInterfaceOrientationUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight When view changed this method called on active view controller. Possible for some views to support auto rotation but not others. Upside down orientation is discouraged as the phone will remain that way if it rings. Most controls default to a setting where items on the screen stay where they are when rotated in relation to the left side and the top of the screen. For larger items specify new positions when view is rotated to prevent overlapping. To change a control’s...

More User Interface Fun (iPhone Dev)

Breaking the process of building a complex application into smaller chunks makes it less intimidating. User interface controls come in 3 basic forms: active, static (or inactive) and passive.  Active Controls involves user participation and something happens (i.e push a button and it fires a method).Static Control like a text label, user does not interact with it.Passive Control is something that holds onto a value until a user needs it. Controls don’t trigger action methods but the user can interact with them and change their values. All iPhone controls are subclasses of UI Control.  Because of multitouch interface, all iPhone controls can trigger multiple actions depending on how they are touched. User may trigger different actions with finger swipe then a touch. Images to be used need to be added to the resources folder.If images and label views have no user interactions then no need to declare actions.Choosing any options that causes images to scale can add processing overhead.Alpha slider any value <1 causes processing overhead as the image is transparent.Text fields are one of the most complex controls on iPhone dev. Keyboard is software based. To make it ‘go away’ need to add code to the controller class.First responder is the control that the user is currently interacting with. Changing UIView to UIControl gives the view the ability to trigger action methods. Fairly common to bounce around xcode and interface builder.Action sheets  and alerts are used to provide the user with feedback. They are used to force the user to make a choice between 2 or more items. They are displayed from the bottom of the screen and...

Handling Basic User Interaction (iPhone Development)

Uses the Model-View-Control methodology. MVC divides all the functionality up into 3 distinct categories. Model – The classes that hold your application’s data View – Made up of the windows, controls and other elements that the user can see and interact with.  Controller – Binds the model and view together and is the application logic that decides how to handle the users input. Controller class can refer to objects in the nib by using a special kind of instance variable called an outlet. An outlet is like a pointer that points to an object within a nib.In the opposite direction , interface objects in the nib can be set up to trigger special methods in the controller class. These special methods are known as action methods. @synthesize tells the compiler to automatically create the accessor and mutator methods for us (getters and setters). Releasing objects when you are done with them is very important as iPhone device is constrained. Delegates are classes that take responsibility for doing certain things on behalf of another object. Hold down the otpion key, move the cursor over the word so it turns into a crosshair, when it does double click!...