简体   繁体   English

XCode 6中通用应用程序和大小类的问题

[英]Trouble with universal app and size classes in XCode 6

With iOS7 creating my universal app was straightforward. 使用iOS7创建通用应用程序非常简单。 Using Storyboard I laid out the iPhone interface and connected the appropriate UI elements to the ViewController. 使用Storyboard,我布置了iPhone界面,并将适当的UI元素连接到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. 完成并正常工作后,只需在第二个Storyboard中创建iPad界面,然后将所有UI元素连接到我用于iPhone的同一ViewController上,就很简单了。

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. 我在XCode 6中遇到的问题是,使用一个故事板(具有大小类),我只能将一个特定大小类的UI元素连接到ViewController。

As an example, I have an iPad interface laid out in wRegular hRegular (iPads in portrait or landscape). 例如,我有一个以wRegular hRegular(纵向或横向的iPad)布置的iPad界面。 I have another UI laid out in wAny hCompact (iPhones in landscape). 我在hCompact(横向放置的iPhone)中布置了另一个UI。 In both UIs I have a UITextView that I want to connect to the single ViewController as an IBOutlet. 在两个UI中,我都有一个UITextView,我想将其作为IBOutlet连接到单个ViewController。 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. 无论在哪个设备上运行,UITextView的功能都是相同的,但是由于两个设备之间的屏幕位置差异很大,因此无法将其放在任何地方。

When I make the connection from the iPhone interface, it automatically deletes the connection from the iPad interface and vice versa. 当我从iPhone界面建立连接时,它会自动从iPad界面删除连接,反之亦然。 This behavior is only when using IBOutlet. 仅当使用IBOutlet时,此行为。 With IBAction the two UIs are able to point at a single method in the ViewController just like before. 使用IBAction,两个UI可以像以前一样指向ViewController中的单个方法。

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 然后,您可以对各种大小类别使用不同的约束来控制对象的大小和位置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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