我有一个iPhone应用程序,它有一个故事板。现在我还想提供一个iPad应用程序。我问自己是否有一个函数可以帮助我将iPhone的故事板转换成iPad的故事板。
具体来说:
是否有类似的功能,还是只有手动的方式?
我有一个iPhone应用程序,它有一个故事板。现在我还想提供一个iPad应用程序。我问自己是否有一个函数可以帮助我将iPhone的故事板转换成iPad的故事板。
具体来说:
是否有类似的功能,还是只有手动的方式?
当前回答
进入目标摘要,将设备更改为通用, 然后向下设置iPad版本为任何你喜欢的故事板,包括一个复制和重命名一个如果你喜欢。
其他回答
这个功能现在是内置的。例如,如果将“部署信息->设备”中的项目设置从iPhone更改为Universal,则会出现以下对话框:
不同的方法
在iPad-Storyboard中添加一个带有Navigation-Controller的empty-View-Controller 将类更改为你的第一个用于iPhone的ViewController的类"fooViewController" 为第一个ViewController添加iPhone-Storyboard "fooViewController_storyboard_identifier"中的Storyboard-Identifier 转到fooviewcontroller。m 添加bool变量bool nibWasLoadForIpad=false 进入viewDidLoad-Method
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad && !nibWasLoadForIpad) { nibWasLoadForIpad = true; UIStoryboard* Storyboard_iphone=[UIStoryboard storyboardWithName:@"Main_iPhone" bundle: nil]; fooViewController *controller = [Storyboard_iphone instantiateViewControllerWithIdentifier:@"fooViewController_storyboard_identifier"]; (自我。导航控制器pushViewController:控制器动画:YES]; 自我。modalPresentationStyle = UIModalPresentationCurrentContext; }
(ps.知道的问题是视图背景将被设置为白色)
如果你创建了一个通用项目,默认情况下会创建空的iPad storyboard,你只需要选择iPhone storyboard select all (Command+ a),复制(Command+C),然后粘贴到iPad storyboard上。在编译之前,请确保将入口点从空故事板移动到新复制的故事板。
我找到了一种解决方案:
Duplicate your iPhone-Storyboard and rename it MainStoryboard_iPad.storyboard Close Xcode and then open this file any text editor. Search for targetRuntime="iOS.CocoaTouch"and change it to targetRuntime="iOS.CocoaTouch.iPad" Change the code in the MainStoryboard_iPad.storyboard from: <simulatedScreenMetrics key="destination" type="retina4"/> to <simulatedScreenMetrics key="destination"/> Now save everything and reopen Xcode. The iPad-Storyboard has the same contents as the iPhone-file but everyting could be disarranged.
这节省了我很多时间,希望这对你们有帮助
当我昨天遇到同样的问题时,我关注了这个帖子。我遵循的步骤
For Xcode 5.1, I had to do some cleanup of iPhone storyboard like missing reuseIdentifiers of Table cells, provide story board id for every controller, remove unused scenes. Copy MainStoryboard_iPhone.storyboard to MainStoryboard_iPad.storyboard. Using vi editor - changed targetRuntime="iOS.CocoaTouch" to targetRuntime="iOS.CocoaTouch.iPad" Change the code in the MainStoryboard_iPad.storyboard from: <simulatedScreenMetrics key="destination" type="retina4"/> to <simulatedScreenMetrics key="destination"/> Open the project in Xcode. Changed the Deployment devices to Universal - Chose the option of NOT copying the iPhone Storyboard. Xcode will default the Deployment Target to 7.1, took care of the deprecated functions. To fix the misplaced view error in iPad Storyboard - Changed the Frame Layout for Controllers giving errors.
就是这样。谢谢你的帮助。