简体   繁体   中英

Trouble with universal app and size classes in XCode 6

With iOS7 creating my universal app was straightforward. Using Storyboard I laid out the iPhone interface and connected the appropriate UI elements to the ViewController. When it was complete and working, it was then a simple matter to create the iPad interface in the second Storyboard and then simply connect all the UI elements to the same ViewController that I used for the iPhone.

The issue that I am having with XCode 6 is that using a single storyboard (with size classes) I am only able to connect a UI element from one specific size class to the ViewController.

As an example, I have an iPad interface laid out in wRegular hRegular (iPads in portrait or landscape). I have another UI laid out in wAny hCompact (iPhones in landscape). In both UIs I have a UITextView that I want to connect to the single ViewController as an IBOutlet. The functionality for the UITextView is the same regardless of which device it is running on, but I can't put it in wAny hAny because of the large difference in screen placement between the two devices.

When I make the connection from the iPhone interface, it automatically deletes the connection from the iPad interface and vice versa. This behavior is only when using IBOutlet. With IBAction the two UIs are able to point at a single method in the ViewController just like before.

The only solution I can think of is two actually use two storyboards which completely defeats the purpose of size classes.

The connection is different to the constraints. You make the connection as hAny wAny because there is only one text view. You then use different constraints for the various size classes to control the size and location of the object

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM