SE-4910i Mobile Application Development -- iOS

Dr. Mark Sebern -- Spring quarter 2014-2015


Student Questions and Answers/Responses

Page 002 Previous page


What does it mean to bridge a type?

Student name: Rebecca Chandler

Date submitted: 23 March 2015


Response

Some of the bridging limitations (as with arrays) result from the lack of support for generics in Objective-C.


Can you use the Auto Layout feature in XCode on only select items in your view?

Student name: Aaron Chun

Date submitted: 19 March 2015


Response

Sometimes the automatic generation of Auto Layout constraints can be useful, but the layout algorithm is only guessing at which relationships are most important. As you suggest, you can partially control the constraint generation process by selecting the UI elements that should be considered. At times, however, enough manual adjustments may be needed that it would be more expedient to create all the constraints yourself (using the XIB/storyboard editor or direct code implementation). The payoff is that a well designed set of constraints can often make an application much more adaptable to display size and orientation.

Student Zach Dam, in a similar submission, suggested the following reference:


Is there a way to set priority for UI element constraints in terms of resolving layout issues?

Student name: Gordon Emmerson

Date submitted: 18 March 2015


Response

Priority setting can be used to provide hints to the iOS auto layout engine on how to handle potentially conflicting constraints. Another option in some cases is to specify a non-equality relation property on some constraints (e.g., "greater than"). More complex constraint specifications are possible, using constraint properties like multiplier. More information is available in the Apple developer documentation at developer.apple.com/library/ios/documentation/AppKit/Reference/NSLayoutConstraint_Class/index.html.


Why am I getting a warning saying the keyboard type (4) is not supported?

Student name: Fred Kimball

Date submitted: 18 March 2015


Response

Having tried this on an actual iPhone 6+, with the same result, it appears that the "simulator setting" approach is a dead end. It fails on at least keyboard types 4, 5, and 8 (corresponding to the drop-down menu on the text field "keyboard type" enum, starting with zero). It appears to be a real defect in iOS 8. The closest thing to an acknowledgement was this link:

stackoverflow.com/questions/27636943/cant-find-keyplane-that-supports-type-4-and-5-on-iphone-5s-ios-8-1-2-and-simula


Why is there nothing showing on my storyboard and the objects in the document outline window are grayed out?

Student name: Tim Koruna

Date submitted: 18 March 2015


Response

As you found out, it is possible to have some storyboard UI elements associated with specific display sizes. If you inadvertently select a different display size, some elements may disappear in the storyboard and be "grayed out" in the document outline.


Swift function parameter naming convention a little odd?

Student name: JJ Cory

Date submitted: 18 March 2015


Response

The special treatment of the first argument to a function, for class methods (functions) only, is primarily a carryover from Objective-C, in order to keep essentially the same method "name" by distributing parts of the Objective-C method name (in this example, incrementBy:numberOfTimes:) to become external names for the remaining parameters.

If Swift were being defined without any concerns for compatibility with existing Objective-C libraries, it is less clear whether this parameter-naming convention would have been adopted. Since Objective-C compatibility clearly was a concern for Apple, the Swift convention is probably a reasonable compromise.


Is there a way to create a UI layout through editing code?

Student name: Joey Betlej

Date submitted: 18 March 2015


Response

The three primary ways to create an iOS user interface are:

Storyboards and XIB files have an internal XML format, but it is uncommon to do much editing by working with the XML directly.