iOS Development (Part 1)


Published on

Familiarization with XCode, iOS Basic Controls, Actions and Properties.
iPhone App Development Training Programme (contd.)

Published in: Technology, Business
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide
  • Symbol navigator: As its name implies, this navigator focuses on the symbols defined in the workspace (see Figure 2–8). Symbols are basically the items that the compiler recognizes, such as Objective-C classes, enumerations, structs, and global variables.
  • When you build your project, any errors or warnings will appear in this navigator, and a message detailing the number of errors will appear in the activity view at the top of the window (see Figure 2–10). When you click an error in the issues navigator, you’ll jump to the appropriate line of code in the editor pane.
  • With a single click, the jump bar allows you to jump to a specific element in the hierarchy you are currently navigating. For example, Figure 2–14 shows a source file being edited in the edit pane.
  • File’s Owner will always be the first icon in any nib file and represents the object that loaded the nib file from disk. First Responder. We’ll talk more about responders later in the book, but in very basic terms, the first responder is the object with which the user is currently interacting. If, for example, the user is currently entering data into a text field, that field is the current first responder. The first responder changes as the user interacts with the interface, and the First Responder icon gives you a convenient way to communicate with whatever control or view is the current first responder without having to write code to determine which control or view that might be.
  • Some controls can work in a passive mode, simply holding on to a value that the user has entered until you’re ready for it. These controls don’t trigger action methods, but the user can interact with them and change their values. A classic example of a passive control is a text field on a web page.
  • The next item, Tag, is worth mentioning, though we won’t be using it in this chapter. All subclasses of UIView, including all views and controls, have a property called tag, which is just a numeric value that you can set here or in code. The tag is designed for your use; the system will never set or change its value. If you assign a tag value to a control or view, you can be sure that the tag will always have that value unless you change it. Interaction Checkboxes The two checkboxes in the Interaction section have to do with user interaction. The first checkbox, User Interaction Enabled, specifies whether the user can do anything at all with this object. For most controls, this box will be checked, because if it’s not, the control will never be able to trigger action methods. However, image views default to unchecked because they are often used just for the display of static information. Since all we’re doing here is displaying a picture on the screen, there is no need to turn this on. The second checkbox is Multiple Touch, and it determines whether this control is capable of receiving multitouch events. Multitouch events allow complex gestures like the pinch gesture used to zoom in in many iOS applications. We’ll talk more about gestures and multitouch events in Chapter 13. Since this image view doesn’t accept user interaction at all, there’s no reason to turn on multitouch events, so leave the checkbox unchecked. Be careful with this one. Alpha defines how transparent your image is—how much of what’s beneath it shows through. Background:The next item down, Background, is a property inherited from UIView, and determines the color of the background for the view. Placeholder, allows you to specify a bit of text that will be displayed in gray inside the text field, but only when the field does not have a value.
  • iOS Development (Part 1)

    1. 1. iOS Development (Part I)COMPILED BY: ASIM RAIS SIDDIQUI (
    2. 2. Goals of the Lecture  Familiarization with XCode  IBOutlet & IBAction  Types of Controls  Common Properties of Xcode Controls  Handling Actions & Controls  Use of Text Fields, Labels, Sliders, Switch Buttons
    3. 3. Xcode Common Sections  The Toolbar  activity view  assistant view  Symbol navigator  Search navigator  Issues navigator
    4. 4. The Toolbar
    5. 5. Project Navigator
    6. 6. Symbol navigator
    7. 7. Issues navigator
    8. 8. The Jump Bar
    9. 9. What’s in the Nib File?  Every nib file starts off with the same two icons, File’s Owner and First Responder. They are created automatically and cannot be deleted.
    10. 10. Outlets and actions  A controller class can refer to objects in a nib file by using a special kind of property called an outlet.  Interface objects in our nib file can be set up to trigger special methods in our controller class. These special methods are known as action methods (or just actions).  @property (nonatomic, retain) IBOutlet UIButton *myButton;  This example is an outlet called myButton, which can be set to point to any button in Interface Builder.
    11. 11. Outlets and actions  Actions  In a nutshell, actions are methods that are declared with a special return type, IBAction, which tells Interface Builder that this method can be triggered by a control in a nib file. The declaration for an action method will usually look like this:  - (IBAction)doSomething:(id)sender;  or like this:  - (IBAction)doSomething;
    12. 12. Action with Multiple Buttons - (IBAction)buttonPressed:(UIButton *)sender { NSString *title = [sender titleForState:UIControlStateNormal]; statusText.text = [NSString stringWithFormat:@"%@ button pressed.", title]; }
    13. 13. Practical
    14. 14. Active, Static, and Passive Controls  Buttons : Active  ImageView : Static  Passive : TextField
    15. 15. Some general control properties  Tag  Interaction Checkboxes  The Alpha Value  Background  Placeholder  Clear Button  Return Key popup  Auto Enable Return Key  Return key secure  Keyboard
    16. 16. Handling actions with Controls #import <UIKit/UIKit.h> @interface BIDViewController : UIViewController @property (strong, nonatomic) IBOutlet UITextField *nameField; @property (strong, nonatomic) IBOutlet UITextField *numberField; - (IBAction)textFieldDoneEditing:(id)sender;  @end  - (IBAction)textFieldDoneEditing:(id)sender { [sender resignFirstResponder];  }
    17. 17. Adding the Slider and Label - (IBAction)sliderChanged:(id)sender { UISlider *slider = (UISlider *)sender; int progressAsInt = (int)roundf(slider.value); sliderLabel.text = [NSString stringWithFormat:@"%d", progressAsInt]; } The first line in the method assigns sender to a UISlider pointer so that the compiler will let us use UISlider methods and properties without warnings.