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".
  • Testing Apps on iOS 7 Devices with Xcode 5 - Techotopia
    Apple Developer Program membership or click on the Join a Program button if you are not yet a member Figure 6 2 Repeat these steps to add additional Apple IDs if you are associated with more than one development team Once the information has been entered the accounts will be listed in the preferences window Generating Signing Identities Before an application can be run on a physical iOS device for testing purposes it must first be signed with a developer signing identity When the application is finished and ready to be placed on sale in the App Store it must first be signed with a distribution signing identity Signing identities are comprised of a certificate and a private key Signing identities can be generated from within the Xcode account preferences panel Begin by selecting the Apple ID for which the identities are to be generated before clicking on the View Details button located in the lower right hand corner of the window This will display a list of signing identities and any provisioning profiles associated with those identities If no valid signing identities are listed as is the cased in Figure 6 3 the next step is to generate them Figure 6 3 Begin by clicking on the button and selecting the iOS Development option from the resulting menu Xcode will then contact the Apple Developer member Center portal and request and download a developer signing identity Repeat these steps this time selecting iOS Distribution from the menu to create and download a distribution signing identity Once completed the two identities should now be listed as shown in Figure 6 4 Figure 6 4 eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Once created signing identities and account information can be migrated to other development computer systems by clicking on the button displaying a gear cog on the first account settings page and selecting the Export Accounts menu option On the destination system repeat these steps this time selecting the Import Accounts option It is worth noting that the certificates associated with the signing identities can also be viewed and created within the Apple Developer Member Center portal Within a browser navigate to the following URL and log in using your Apple ID credentials https developer apple com membercenter Within the member center click on the Certificates Identifiers and Profiles option and choose Certificates from the list of options under the iOS Apps category On the resulting page the certificates for both signing identifies should be listed Clicking on certificate will display details such as the expiration date as outlined in Figure 6 5 Figure 6 5 As can be seen in the left hand panel of Figure 6 5 the member center also provides options to manually create App IDs and Provisioning Profiles With Xcode 5 however

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


  • Creating an Interactive iOS 7 App - Techotopia
    we need When we created our new project Xcode anticipated our needs and automatically created a subclass of UIViewController and named it UnitConverterViewController using the class prefix entered when the project was initially created In so doing Xcode also created two source files a header file named UnitConverterViewController h and a source code file named UnitConverterViewController m Selecting the UnitConverterViewController h file in the Xcode project navigator panel will display the contents of the file in the editing pane import UIKit UIKit h interface UnitConverterViewController UIViewController end As we can see from the above 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 This could be achieved by manually declaring the outlets and actions within the UnitConverterViewController h file A much easier approach is to use the Xcode Assistant Editor to do this for us eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters With the Main storyboard file selected display the Assistant Editor by selecting the View Assistant Editor Show Assistant Editor menu option Alternatively it may also be displayed by selecting the center button the one containing an image of a bow tie and tuxedo of the row of Editor toolbar buttons in the top right hand corner of the main Xcode window as illustrated in the following figure Figure 11 4 In the event that multiple Assistant Editor panels are required additional tiles may be added using the View Assistant Editor Add Assistant Editor menu option By default the editor panel will appear to the right of the main editing panel in the Xcode window For example in Figure 11 5 the panel to the immediate right of the Interface Builder panel is the Assistant Editor Figure 11 5 By default the Assistant Editor will be in Automatic mode whereby it automatically attempts to display the correct source file based on the currently selected item in Interface Builder If the correct file is not displayed use the toolbar along the top of the editor panel to select the correct file The small instance of the tuxedo icon in this toolbar can be used to switch to Manual mode allowing the file to be selected from a pull right menu containing all the source files in the project Make sure that the UnitConverterViewController h file is displayed in the Assistant Editor and establish an outlet for the Text Field object by ctrl clicking on the Text Field object in the view and drag the resulting line to the area immediately beneath the interface directive in the Assistant Editor panel as illustrated in Figure 11 6 Figure 11 6 Upon releasing the line the configuration panel illustrated in

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

  • Writing iOS 7 Code to Hide the Keyboard - Techotopia
    Field object from the Object Library panel View Utilities Show Object Library onto the View area Now that we have the user interface designed we need to create an outlet so that we can reference our text field from our view controller code Within the main Xcode window display the Assistant Editor make sure it is displaying the contents of the HideKeyboardViewController h file and Ctrl click and drag from the text field object to a point below the interface line in the Assistant Editor panel In the resulting connection dialog name the outlet textField and click on Connect Select the HideKeyboardViewController h file and verify that the outlet has been established correctly import UIKit UIKit h interface HideKeyboardViewController UIViewController property strong nonatomic IBOutlet UITextField textField end eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters 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 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 interface HideKeyboardViewController end implementation HideKeyboardViewController 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 device 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 the Main storyboard file 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 view controller icon located in the panel immediately beneath the view canvas in the Interface Builder panel as shown in Figure 12 1 Figure 12 1 Release the line and select the textFieldReturn method from the list of available methods in the resulting panel 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

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

  • An Introduction to Auto Layout in iOS 7 - Techotopia
    now permitted to grow in width up to the specified limit allowing longer content to be displayed without clipping Auto layout constraints are by nature interdependent and as such situations can arise where a constraint on one view competes with a constraint on another view to which it is connected In such situations it may be necessary to make one constraint stronger and the other weaker in order to provide the system with a way of arriving at a layout solution This is achieved by assigning priorities to constraints Priorities are assigned on a scale of 0 to 1000 with 1000 representing a required constraint and lower numbers equating to optional constraints When faced with a decision between the needs of a required constraint and an optional constraint the system will meet the needs of the required constraint exactly while attempting to get as close as possible to those of the optional constraint In the case of two optional constraints the needs of the constraint with the higher priority will be addressed before those of the lower Alignment Rects When working with constraints it is important to be aware that constraints operate on the content of a view not the frame in which a view is displayed This content is referred to as the alignment rect of the view Alignment constraints such as those that cause the center of one view to align with that of another will do so based on the alignment rects of the views disregarding any padding that may have been configured for the frame of the view Intrinsic Content Size Some views also have what is known as an intrinsic content size This is the preferred size that a view itself believes it needs to be to display its content to the user A Button view for example will have an intrinsic content size in terms of height and width that is based primarily on the text or image it is required to display and internal rules on the margins that should be placed around that content When a view has an intrinsic content size auto layout will automatically assign two constraints for each dimension for which the view has indicated an intrinsic content size preference i e height and or width One constraint is intended to prevent the size of the view becoming larger than the size of the content otherwise known as the content hugging constraint The other constraint is intended to prevent the view from being sized smaller than the content referred to as the compression resistance constraint Content Hugging and Compression Resistance Priorities The resize behavior of a view with an intrinsic content size can be controlled by specifying compression resistance and content hugging priorities A view with a high compression resistance priority and a low content hugging priority will be allowed to grow but will resist shrinking in the corresponding dimension Similarly a high compression resistance priority in conjunction with a high content hugging priority will cause the view to

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

  • Working with iOS 7 Auto Layout Constraints in Interface Builder - Techotopia
    5 provides a wide range of options and visual cues that are designed to ease the task of creating auto layout constraints The Auto Layout Features of Interface Builder A number of features have been added to Xcode 5 in order to assist in the implementation of auto layout based constraints This section will present a guided tour of these features Suggested Constraints When objects are added to a layout canvas Interface Builder does not implement any default constraints on those views leaving the developer to add constraints as needed There is however the option to have Interface Builder apply suggested constraints When this option is used Interface Builder will apply what it believes to be the correct constraints for the layout based on the positioning of the views Suggested constraints can be added either to the currently selected view objects or to an entire scene layout In situations where constraints are missing from a layout resulting in warnings Interface Builder also provides the option to automatically add the constraints that it believes are missing The options to perform these tasks are accessed via the Resolve Auto Layout Issues menu in the toolbar as illustrated in Figure 15 10 The top section of the menu represents tasks that relate to the currently selected views in the canvas whilst the options in the lower section apply to all views in the currently selected view controller scene Figure 15 10 Most of the time the suggested constraints will exactly match the required layout behavior and occasionally the suggested constraints will be incorrect Most of the time however the suggested constraints provide an excellent starting point for implementing auto layout A typical process for designing a user interface might therefore involve positioning the views by dragging and dropping them into place applying suggested constraints and then editing and fine tuning those constraints to perfect the layout To see suggested constraints in action select the label view in the AutoLayout project and select the Clear Constraints option from the Resolve Auto Layout Issues menu At this point there are no constraints in the layout and the old positioning problem appears when the view is rotated With the label still selected choose the Reset to Suggested Constraints menu option A review of the view canvas and change of orientation should demonstrate that Interface Builder has suggested and applied the exact same constraints that we previously added manually Visual Cues Interface Builder includes a number of visual cues in the layout canvas to highlight the constraints currently configured on a view and to draw attention to areas where problems exist When a view is selected within the layout canvas the constraints that reference that view will be represented visually Consider for example the label view created in our AutoLayout example application When selected in the canvas a number of additional lines appear as shown in Figure 15 11 Figure 15 11 The vertical line that runs through the center of the label indicates the presence of a constraint that positions the label in the horizontal center of the parent view analogous to the NSLayoutAttributeCenterX attribute If expressed as an equation therefore this would read as label NSLayoutAttributeCenterX superview NSLayoutAttributeCenterX The I beam line running from the bottom edge of the label view to the bottom edge of the parent view indicates that a vertical space constraint is in place between the two views The absence of any additional visual information on the line indicates that this is an equality constraint Figure 15 12 shows an example of a greater than or equal to horizontal constraint between two button views Figure 15 12 The horizontal line running beneath the Button label text indicates that constraints are in place to horizontally align the content baseline represented by NSLayoutAttributeBaseline of the two buttons Width constraints are indicated by an I beam line running parallel to the edge of the view in the corresponding dimension The text view object in Figure 15 13 for example has a greater than or equal to width constraint configured Figure 15 13 eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Highlighting Constraint Problems google ADSDAQBOX FLOW google Interface Builder also uses a range of visual cues and decorations to indicate that constraints are either missing ambiguous or in conflict Valid and complete auto layout configurations are drawn using blue lines When part of a layout is ambiguous the constraint lines are orange Ambiguity typically occurs when a constraint is missing Take for example the label view used earlier in the chapter If only the horizontal center constraint is set that constraint line will appear in orange because auto layout does not know where to position the view in the vertical plane Once the second constraint is set between the bottom edge of the label and the bottom of the superview the constraint line will turn blue to indicate that the layout is no longer ambiguous Red constraint lines are used to indicate that constraints are in conflict Consider for example a view object on which two width constraints have been configured each for a different width value The auto layout system categorizes such a situation as a constraint conflict and Interface Builder draws the offending constraint lines on the layout canvas in red Figure 15 14 for example illustrates a conflict where one constraint is attempting to set the width of a view to 94 points while a second constraint dictates that the width must be greater than or equal to 99 points Figure 15 14 The layout canvas does not dynamically update the positions and sizes of the views that make up a user interface as constraints are added It is possible therefore to have constraints configured that will result in layout behavior different to that currently displayed within the canvas

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

  • An iOS 7 Auto Layout Example - Techotopia
    16 5 With the label still selected use the Align menu to constrain the label to the horizontal center of the container All that now remains is to establish some constraints between the two labels Ctrl click on the left most label and drag the line to the right hand label before releasing the line From the resulting menu hold down the Shift key on the keyboard and select the Baseline and Horizontal Spacing options to align the content baselines of the two labels and to add a spacing constraint With both options selected hit the keyboard return key to add the constraints With the basic constraints implemented display the Resolve Auto Layout Issues menu and select the option to update all frames in the view controller Using the Simulated Metrics once again rotate the view to Landscape mode and note that the layout now re organizes to accommodate the orientation change Figure 16 6 eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Adjusting Constraint Priorities Up until this point the layout is behaving correctly using basic constraints with default priorities We are now however going to introduce some problems that cannot be handled adequately by the constraints as they currently stand With the view still in landscape mode double click on the left hand label and change the text so that it reads Customer Record Using the Attributes Inspector change the Alignment property so that the text is right aligned With the view in landscape mode the label appears correctly positioned Rotate the view to portrait orientation however and the label is clearly being clipped by the left hand edge of the parent view Figure 16 7 Clearly there is some work to be done to make the user interface appear correctly in both orientations The first step is to consider the constraints that are currently set on the label views The right hand label has a constraint that forces it to be centered horizontally in the parent view The left hand label on the other hand has a constraint that connects its trailing edge to the leading edge of the second label The absence of a constraint on the left hand edge of the Customer Record label is resulting in the label being pushed off the screen in portrait mode One possible solution to this problem might be to create a new constraint on the Customer Record label that puts some space between the left hand edge of the customer record label and the left hand edge of the parent view To add this constraint rotate the view back to landscape so that the label is fully visible select the Customer Record label display the Pin menu and establish a standard space constraint between the left hand edge of the view and the nearest neighbor Before

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

  • Implementing iOS 7 Auto Layout Constraints in Code - Techotopia
    is set to nil Adding a Constraint to a View Once a constraint has been created it needs to be assigned to a view in order to become active This is achieved by passing it through as an argument to the addConstraint method of the view instance to which it is being added In the case of multiple constraints each is added by a separate call to the addConstraint method This leads to the question of how to decide which view the constraint should be added to In the case of a constraint that references a single view the constraint must be added to the immediate parent of the view When a constraint references two views the constraint must be applied to the closest ancestor of the two views Consider for the purposes of an example the view hierarchy illustrated in Figure 17 1 Figure 17 1 A constraint referencing only Label A should be added to the immediate parent in this case View B A constraint referencing Button B and Label B on the other hand must be added to the nearest common ancestor which in this case is View C A constraint referencing Button A and Button B must once again be added to the nearest common ancestor which equates to View A For the purposes of an example the following code excerpt creates a new constraint and adds it to a view NSLayoutConstraint myConstraint NSLayoutConstraint constraintWithItem mybutton attribute NSLayoutAttributeWidth relatedBy NSLayoutRelationEqual toItem mylabel attribute NSLayoutAttributeWidth multiplier 5 constant 0 superview addConstraint myConstraint eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Turning off Auto Resizing Translation When adding views to a layout in code the toolkit will by default attempt to convert the autosizing mask for that view to auto layout constraints Unfortunately those auto generated constraints will conflict with any constraints added within the application code It is essential therefore that translation be turned off for views to which constraints are to be added This is achieved by calling the setTranslatesAutoresizingMaskIntoConstraints method of the target view passing through NO as an argument For example the following code creates a new Button view turns off translation and then adds it to the parent view UIButton mybutton UIButton buttonWithType UIButtonTypeRoundedRect mybutton setTitle My Button forState UIControlStateNormal mybutton setTranslatesAutoresizingMaskIntoConstraints NO superview addSubview mybutton An Example Application Create a new Xcode project for the iPhone or iPad using the Single View Application template Enter AutoLayoutCode as the product name and class prefix Creating the Views For the purpose of this example the code to create the views and constraints will be added to the viewDidLoad method of the AutoLayoutCode view controller Select the AutoLayoutCodeViewController m file locate this method and modify it to create a button and a label and add them to the main view void viewDidLoad super

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

  • Implementing Cross-Hierarchy Auto Layout Constraints in iOS 7 - Techotopia
    view and change the background color to a light shade of grey using the Attributes Inspector Drag and drop UIView Button and label views onto the design canvas as illustrated in Figure 18 2 making sure to center the label object horizontally and vertically within the parent view Select the newly added view object click on the Resolve Auto Layout Issues menu from the toolbar in the lower right hand corner of the canvas and select the Reset to Suggested Constraints option Repeat these steps for both the label and button views Establishing Outlets In order to set a cross hierarchy constraint within code it will be necessary to implement some outlets Since the constraint will need to reference both the button and the label outlets need to be configured for these views Select the label object and display the Assistant Editor using the View Assistant Editor Show Assistant Editor menu option or by selecting the center button the one containing an image of a bow tie and tuxedo of the row of Editor toolbar buttons in the top right hand corner of the main Xcode window Make sure that the editor is showing the CrossViewViewController h file Ctrl click on the Label object in the view and drag the resulting line to the area immediately beneath the interface directive in the Assistant Editor panel Upon releasing the line the configuration panel will appear Configure the connection as an Outlet named myLabel and click on the Connect button Repeat the above steps to add an outlet for the button object named myButton As currently constrained the label object is centered horizontally and vertically within the view we are referring to as View B In place of this constraint we need the label to be aligned with the center of the button object This will involve removing the CenterX constraint and replacing it with a new constraint referencing the button This requires outlets for both the View B instance and the CenterX constraint eBookFrenzy com Purchase the fully updated iOS 9 Swift 2 Xcode 7 edition of this book in eBook 12 99 or Print 39 99 format iOS 9 App Development Essentials Print and eBook ePub PDF Kindle edition contains 105 chapters Ctrl click on the View B parent of the label object and drag the resulting line to the area immediately beneath the interface directive in the Assistant Editor Release the line and configure an outlet named viewB Next select the label object so that the associated constraint lines appear Click on the vertical line passing through the label view so that it highlights Ctrl click on the constraint line and drag to the Assistant Editor panel Figure 18 3 and create a new outlet for this object named centerConstraint Figure 18 3 Writing the Code to Remove the Old Constraint With the necessary outlets created the next step is to write some code to remove the center constraint from the label object For the purposes of this example

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



  •