archive-com.com » COM » T » TECHOTOPIA.COM

Total: 1018

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • Installing Xcode 4 and the iOS 5 SDK - Techotopia
    an Intel based processor then your current system is sadly unsuitable as a platform for iPhone iOS app development In addition the iOS 5 SDK with Xcode 4 2 environment requires that the version of Mac OS X running on the system be version 10 6 6 or later If the About This Mac dialog does not indicate that Mac OS X 10 6 6 or later is running click on the Software Update button to download and install the appropriate operating system upgrades Installing Xcode 4 and the iOS 5 SDK The best way to obtain the latest versions of Xcode 4 and the iOS SDK is to download them from the Apple iOS Dev Center web site at http developer apple com devcenter ios index action In order to download Xcode 4 with the iOS 5 SDK you will either need to be a member of the iOS Developer programs or purchase a copy from the Mac App Store at http itunes apple com us app xcode id422352214 mt 12 ls 1 The download is over 3 5GB in size and may take a number of hours to complete depending on the speed of your internet connection The package takes the form of a disk image dmg file Once the download has completed a new window will open as follows displaying the contents of the dmg file Figure 5 2 If this window does not open by default it can be opened by clicking on the SDK disk drive icon on the desktop or by navigating to the Downloads directory of your home folder and double clicking on the corresponding dmg file Initiate the installation by double clicking on the package icon the one that looks like an opening box and follow the instructions until you reach the

    Original URL path: http://www.techotopia.com/index.php/Installing_Xcode_4_and_the_iOS_5_SDK (2016-02-13)
    Open archived version from archive


  • Creating a Simple iPhone iOS 5 App - Techotopia
    the xib file is the save files used by the Interface Builder tool to hold the user interface design we will create Older versions of Interface Builder saved designs in files with a nib extension so these files even today are called NIB files Also present will be one or more files with a plist file extension These are Property List files which contain key value pair information For example the HelloWorld info plist file contains resource settings relating to items such as the language icon file executable name and app identifier The list of files is displayed in the Project Navigator located in the left hand panel of the main Xcode project window A toolbar at the top of this panel contains options to display other information such as build and run history breakpoints compilation errors and warnings symbol navigator and a search panel By default the center panel of the window shows a summary of the settings for the application This includes the identifier specified during the project creation process and the target device Options are also provided to configure the orientations of the device that are to be supported by the application together with options to upload an icon the small image the user selects on the device screen to launch the application and splash screen image displayed to the user while the application loads for the application In addition to the Summary screen tabs are provided to view and modify additional settings consisting of Info Build Settings Build Phases and Build Rules As we progress through subsequent chapters of this book we will explore some of these other configuration options in greater detail To return to the Summary panel at any future point in time make sure the Project Navigator is selected in the left hand panel and select the top item the application name in the navigator list When a source file is selected from the list in the navigator panel the contents of that file will appear in the center panel where it may then be edited To open the file in a separate editing window simply double click on the file in the list Creating the iOS App User Interface Simply by the very nature of the environment in which they run iPhone apps are typically visually oriented As such a key component of just about any app involves a user interface through which the user will interact with the application and in turn receive feedback Whilst it is possible to develop user interfaces by writing code to create and position items on the screen this is a complex and error prone process In recognition of this Apple provides a tool called Interface Builder which allows a user interface to be visually constructed by dragging and dropping components onto a canvas and setting properties to configure the appearance and behavior of those components Interface Builder was originally developed some time ago for creating Mac OS X applications but has now been updated to

    Original URL path: http://www.techotopia.com/index.php/Creating_a_Simple_iPhone_iOS_5_App (2016-02-13)
    Open archived version from archive

  • Testing iOS 5 Apps on the iPhone – Developer Certificates and Provisioning Profiles - Techotopia
    devices per year A new device may be added to the list of supported test devices either from within the Xcode Organizer window or by logging into the iOS Developer Portal and manually adding the device To add a device to the portal from within Organizer simply connect the device open the Organizer window in Xcode using the Organizer toolbar button select the attached device from the left hand panel and click on the Add to Portal button The Organizer will prompt for the developer portal login and password before connecting and enabling the device for testing Manually adding a device on the other hand requires the use of the iPhone s UDID This may be obtained either via Xcode or iTunes Begin by connecting the device to your computer using the docking connector Once Xcode has launched the Organizer window will appear displaying summary information about the device or may be opened by selecting the Organizer button in the Xcode toolbar The UDID is listed next to the Identifier label as illustrated in Figure 7 8 Figure 7 8 Alternatively launch iTunes select the device in the left hand pane and review the Summary information page One of the fields on this page will be labeled as Serial Number Click with the mouse on this number and it will change to display the UDID Having identified the UDIDs of any devices you plan to use for app testing select the Devices link located in the left hand panel of the iOS Provisioning Portal and click on Add Devices in the resulting page On the Add Devices page enter a descriptive name for the device and the 40 character UDID Figure 7 9 In order to add more than one device at a time simply click on the button to create more input fields Once you have finished adding devices click on the Submit button The newly added devices will now appear on the main Devices page of the portal Creating an App ID The next step in the process is to create an App ID for each app that you create This ID allows your app to be uniquely identified within the context of the Apple iOS ecosystem To create an App ID select the App IDs link in the provisioning portal and click on the New App ID button to display the Create App ID screen as illustrated in Figure 7 10 Figure 7 10 Enter a suitably descriptive name into the Description field and then make a Bundle Seed ID selection If you have not created any previous Seed IDs then leave the default Generate New selection unchanged If you have created a previous App ID and would like to use this for your new app click on the menu and select the desired ID from the drop down list Finally enter the Bundle Identifier This is typically set to the reversed domain name of your company followed by the name of the app For example if

    Original URL path: http://www.techotopia.com/index.php/Testing_iOS_5_Apps_on_the_iPhone_%E2%80%93_Developer_Certificates_and_Provisioning_Profiles (2016-02-13)
    Open archived version from archive

  • An Overview of the iPhone iOS 5 Application Development Architecture - Techotopia
    and Controller components are objects It is also worth pointing out that applications are not restricted to a single model view and controller In fact an app can consist of multiple view objects controller objects and model objects The way that a view controller object interacts with a Model is through the methods and properties exposed by that model object This in fact is no different from the way one object interacts with another in any object oriented programming environment In terms of the view controller s interactions with the view however things get a little more complicated In practice this is achieved using the Target Action pattern together with Outlets and Actions The Target Action pattern IBOutlets and IBActions When you create an iOS 5 iPhone app you will typically design the user interface the view using the Interface Builder tool and write the view controller and model code in Objective C using the Xcode code editor The previous section looked briefly at how the view controller interacts with the model In this section we will look at how the view created in Interface Builder and our view controller code interact with each other When a user interacts with objects in the view for example touching and releasing a button control an event is triggered in this case the event is called a Touch Up Inside event The purpose of the Target Action pattern is to allow you to specify what happens when such events are triggered In other words this is how you connect the objects in the user interface you have designed in the Interface Builder tool to the back end Objective C code you have written in the Xcode environment Specifically this allows you to define which method of which controller object gets called when a user interacts in a certain way with a view object The process of wiring up a view object to call a specific method on a view controller object is achieved using something called an Action An action is a method defined within a view controller object that is designed to be called when an event is triggered in a view object This allows us to connect a view object created within a nib file using Interface Builder to the code that we have written in the view controller class This is one of the ways that we bridge the separation between the View and the Controller in our MVC design pattern As we will see in Creating an Interactive iOS 5 iPhone App action methods are declared using the IBAction keyword The opposite of an Action is the Outlet As previously described an Action allows a view object to call a method on a controller object An Outlet on the other hand allows a view controller object method to directly access the properties of a view object A view controller might for example need to set the text on a UILabel object In order to do so an Outlet must

    Original URL path: http://www.techotopia.com/index.php/An_Overview_of_the_iPhone_iOS_5_Application_Development_Architecture (2016-02-13)
    Open archived version from archive

  • Creating an Interactive iOS 5 iPhone App - Techotopia
    code a new class called UnitConverterViewController has been created that is a subclass of the UIViewController class belonging to the UIKit framework The next step is to extend the subclass to include the two outlets and our action method We will begin by adding outlets for our text field and label objects by declaring variables and using the IBOutlet keyword import UIKit UIKit h interface UnitConverterViewController UIViewController UITextField tempText UILabel resultLabel property strong nonatomic IBOutlet UILabel resultLabel property strong nonatomic IBOutlet UITextField tempText end Next we need to declare the action that will be called when the user touches the Convert button in our user interface This is declared using the IBAction keyword import UIKit UIKit h interface UnitConverterViewController UIViewController UITextField tempText UILabel resultLabel property strong nonatomic IBOutlet UILabel resultLabel property strong nonatomic IBOutlet UITextField tempText IBAction convertTemp id sender end We have now declared that our View Controller class contains a method called convertTemp Having made that declaration we need to implement the method in the implementation source file To do so select the UnitConverterViewController m file so that the contents appear in the editing pane import UnitConverterViewController h implementation UnitConverterViewController void didReceiveMemoryWarning super didReceiveMemoryWarning Release any cached data images etc that aren t in use pragma mark View lifecycle void viewDidLoad super viewDidLoad void viewDidUnload super viewDidUnload Release any retained subviews of the main view e g self myOutlet nil void viewWillAppear BOOL animated super viewWillAppear animated void viewDidAppear BOOL animated super viewDidAppear animated void viewWillDisappear BOOL animated super viewWillDisappear animated void viewDidDisappear BOOL animated super viewDidDisappear animated BOOL shouldAutorotateToInterfaceOrientation UIInterfaceOrientation interfaceOrientation Return YES for supported orientations return interfaceOrientation UIInterfaceOrientationPortraitUpsideDown end The first step is to instruct Objective C to synthesize accessor methods for our tempText and resultLabel objects and then to implement the convertTemp method The relevant section of the UnitConverterViewController m file should now read as follows import UnitConverterViewController h implementation UnitConverterViewController synthesize resultLabel tempText void convertTemp id sender double farenheit tempText text doubleValue double celsius farenheit 32 1 8 NSString resultString NSString alloc initWithFormat Celsius f celsius resultLabel text resultString Before we proceed it is probably a good idea to pause and explain what is happening in the above code Those already familiar with Objective C however may skip the next few paragraphs In this file we are implementing the convertTemp method originally declared in the h file This method takes as a single argument a reference to the sender The sender is the object that triggered the call to the method in this case our Button object Whilst we won t be using this object in the current example this can be used to create a general purpose method in which the behavior of the method changes depending on how i e via which object it was called We could for example create two buttons labeled Convert to Fahrenheit and Convert to Celsius respectively each of which calls the same convertTemp method The method would then access the sender object to identify which button

    Original URL path: http://www.techotopia.com/index.php/Creating_an_Interactive_iOS_5_iPhone_App (2016-02-13)
    Open archived version from archive

  • Writing iOS 5 Code to Hide the iPhone Keyboard - Techotopia
    outlet by holding down the Ctrl key while clicking and dragging with the mouse from the File s Owner icon to the text field object in the View From the resulting menu select the textField outlet Hiding the Keyboard when the User Touches the Return Key The next step is to wire up our application so that the keyboard is dismissed when the user touches the keyboard Return key To do so we need to write a method that will resign the first responder on the text field in other words hide the keyboard when the return key is pressed Begin by editing the hideKeyboardViewController h interface file to declare the method which we will name textFieldReturn import UIKit UIKit h interface hideKeyboardViewController UIViewController UITextField textField property strong nonatomic IBOutlet UITextField textField IBAction textFieldReturn id sender end Having declared the method we now need to implement it in the hideKeyboardViewController m implementation file import hideKeyboardViewController h implementation hideKeyboardViewController synthesize textField IBAction textFieldReturn id sender sender resignFirstResponder end In the above method we are making a call to the resignFirstResponder method of the object that triggered the event The first responder is the object with which the user is currently interacting in this instance the virtual keyboard displayed on the iPhone screen Having written the code for our method we now need to wire up our user interface so that it gets called at the appropriate time We will perform this task in Interface Builder so select hideKeyboardViewController xib once more Select the text field in the view and display the Connections Inspector View Utilities Connections Inspector in the right hand panel Click on the circle to the right of the Did End on Exit event drag the line to the File s Owner icon and select textFieldReturn from the list of available methods Click on the Run button in the Xcode toolbar When the application appears in the iOS Simulator select the text field so that the keyboard appears and then touch the Return key The keyboard should subsequently disappear from view Hiding the Keyboard when the User Taps the Background The second mechanism for hiding the keyboard involves wiring up an event to be called when the user touches the background view of the screen We will begin the process by writing the action method to perform this task From within Xcode select the hideKeyboardViewController h file and add a declaration for our new backgroundTouched action method import UIKit UIKit h interface hideKeyboardViewController UIViewController UITextField textField property nonatomic strong IBOutlet UITextField textField IBAction textFieldReturn id sender IBAction backgroundTouched id sender end Select the hideKeyboardViewController m file and implement the action by calling the resignFirstResponder method of our textField object import hideKeyboardViewController h implementation hideKeyboardViewController synthesize textField IBAction textFieldReturn id sender sender resignFirstResponder IBAction backgroundTouched id sender textField resignFirstResponder end Having written the code for our action method we now need to make sure it gets called when the user touches the background view This involves some work in Interface

    Original URL path: http://www.techotopia.com/index.php/Writing_iOS_5_Code_to_Hide_the_iPhone_Keyboard (2016-02-13)
    Open archived version from archive

  • Understanding iOS 5 iPhone Views, Windows and the View Hierarchy - Techotopia
    will discuss in the next section The user does not see or interact directly with the UIWindow object These windows may be created programmatically but are typically created automatically by Interface Builder when you design your user interface The View Hierarchy iPhone iOS 5 user interfaces are constructed using a hierarchical approach whereby different views are related through a parent child relationship At the top of this hierarchy sits the UIWindow object Other views are then added to the hierarchy If we take the example from the chapter entitled Creating an Interactive iOS 5 iPhone App we have a design that consists of a window a view a text field a button and a label The view hierarchy for this user interface would be drawn as illustrated in Figure 13 1 Figure 13 1 In this example the UIWindow object is the parent or superview of the UIView instance and the UIView is the child or subview of the UIWindow Similarly the text label and button objects are all subviews of the UIView A subview can only have one direct parent As shown in the above example however a superview may have multiple subviews In addition view hierarchies can be nested to any level of depth Consider for example the following hierarchy diagram Figure 13 2 The hierarchical structure of a user interface has significant implications for how the views appear and behave Visually subviews always appear on top of and within the visual frame of their corresponding parent The button in the above example therefore appears on top of the parent view in the running application Furthermore the resizing behavior of subviews in other words the way in which the views change size when the device is rotated is defined in relation to the parent view Superviews also have the ability to modify the positioning and size of their subviews If we were to design the above nested view hierarchy in Interface Builder it might appear as illustrated in Figure 13 3 In this example the UIWindow instance is not visible because it is fully obscured by the UIView1 instance Displayed on top of and within the frame of UIView1 are the UIButton1 UILabel and UIView2 subviews Displayed on top of and within the frame of UIView2 are its respective subviews namely UIButton2 and UIImageView Figure 13 3 The view hierarchy also defines how events are handled when a user interacts with the interface essentially defining something called the responder chain If for example a subview receives an event that it cannot handle that event is passed up to the immediate superview If that superview is also unable to handle the event it is passed up to the next parent and so on until it reaches a level within the responder chain where it can be dealt with View Types Apple groups the various views included in the UIKit framework into a number of different categories The Window The UIWindow is the root view of the view hierarchy and

    Original URL path: http://www.techotopia.com/index.php/Understanding_iOS_5_iPhone_Views,_Windows_and_the_View_Hierarchy (2016-02-13)
    Open archived version from archive

  • IOS 5 iPhone Rotation, View Resizing and Layout Handling - Techotopia
    14 1 In order to gain an appreciation of the importance of handling orientation changes save the design and build and run the application Once the simulator appears rotate the device by 90⁰ Because rotation is enabled the view will rotate to the landscape orientation Figure 14 2 Here we see a classic example of the implications of enabling rotation in an application without taking the additional steps to reformat the view to match the change in orientation Having rotated the device only the top button is visible and it is still centered assuming that the device is in portrait mode The second button is similarly positioned resulting in it being outside the viewable area of the screen In order to ensure the correct layout of the user interface it is necessary to make some changes to the autosize settings of the two buttons The current settings for a view are accessed from within Interface Builder by selecting the component and displaying the Size Inspector View Utilities Show Size Inspector Figure 14 3 shows the Size Inspector for the top button in our user interface Figure 14 3 The section of this window that is of interest to us is the area labeled Autosizing and in particular the white box on the left The outer box represents the superview and the inner box represents the subview that is contained within the superview Any autosizing settings that are configured on a subview are relative to the superview Within the subview box are two intersecting lines with arrows at each end These vertical and horizontal lines indicate whether the height and width of the selected view object should increase or decrease in proportion to size changes in the corresponding superview A faint dotted line indicates that the currently selected view object is not to resize in relation to the superview A solid red line on the other hand indicates that it should resize proportionally to the parent view The graphic to the right of the white box provides a visual representation of how the view will behave based on the current settings The red box represents the subview and the white box represents the containing superview Click on the horizontal line to change it to solid red and see how the width of the red box representing the button grows and shrinks as the containing superview size changes Similarly enable resizing for the height of the button and observe how the height of the button also now changes proportionally to the superview Figure 14 4 These two settings correspond to the UIViewAutoResizingFlexibleHeight and UIViewAutoResizing FlexibleWidth autoresizing mask properties The lines separating the four sides of the inner subview and the outer superview boxes are referred to as struts and control what happens to the margin between each side of the subview and the corresponding sides of the superview when the latter resizes as the result of an orientation change When a strut is enabled indicated by the solid red lines the corresponding

    Original URL path: http://www.techotopia.com/index.php/IOS_5_iPhone_Rotation,_View_Resizing_and_Layout_Handling (2016-02-13)
    Open archived version from archive



  •