iOS: 创建universal app

iOS: 创建universal app,第1张

概述universal app supports both ipad and iphone。要了解universal如何支持both ipad and iphone,最直接的方法就是创建一个universal project。 universal project的基本特点: 1. target > summary > devices is universal 2. xib for ipad and x

universal app supports both ipad and iphone。要了解universal如何支持both ipad and iphone,最直接的方法就是创建一个universal project。

universal project的基本特点:

1. target > summary > devices is universal


2. xib for ipad and xib for iphone can share the same vIEw controller,当然使用不同的vIEw controller绝对没问题。

3. in appdelegate.m dIDFinishLaunchingWithOptions method,use following code to 根据device是ipad还是iphone来指定 access 不同的 vIEw

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {        self.vIEwController = [[VIEwController alloc] initWithNib@R_404_6889@:@"VIEwController_iPhone" bundle:nil];    } else {        self.vIEwController = [[VIEwController alloc] initWithNib@R_404_6889@:@"VIEwController_iPad" bundle:nil];    }
    self.window.rootVIEwController = self.vIEwController;
[self.window makeKeyAndVisible];


4. 其他class还可以通过

[[UIDevice currentDevice] userInterfaceIdiom]
来判断是ipad还是iphone来执行不同的代码


如何把iphone app转换成universal app?

非常简单,只需要把target > summary > devices option设置为universal即可。当然你要自己创建一组for ipad的ui,并在delegate.m里根据device指定不同的vIEw。


ref links:

http://richielin-programer.blogspot.com/2010/06/iphone-ipad-universal-app.html

http://iphonedevelopment.blogspot.com/2010/04/converting-iphone-apps-to-universal.html

总结

以上是内存溢出为你收集整理的iOS: 创建universal app全部内容,希望文章能够帮你解决iOS: 创建universal app所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1091264.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存