使程序同时支持iphone和ipad

使程序同时支持iphone和ipad,第1张

概述在AppDelegate里,通过获取UIDevice的userInterfaceIdiom属性,可以检测到当前程序是运行在iphone或者是ipad上,分别加载相应的视图,就能在两种设备中正常的运行起来。 例子如下:         UIDevice* device=[UIDevice currentDevice]; window = [[UIWindow alloc] initWithFrame AppDelegate里,通过获取UIDevice的userInterfaceIdiom属性,可以检测到当前程序是运行在iphone或者是ipad上,分别加载相应的视图,就能在两种设备中正常的运行起来。 例子如下:

        UIDevice* device=[UIDevice currentDevice]; window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; if (device.userInterfaceIdiom==UIUserInterfaceIdiomPhone) { IPhoneVIEwController* IPhoneVIEwController1=[[IPhoneVIEwController alloc]init]; window.rootVIEwController= IPhoneVIEwController1; [IPhoneVIEwController1 release]; } else if (device.userInterfaceIdiom==UIUserInterfaceIdiomPad)  { IPadVIEwController* IPadVIEwController1=[[IPadVIEwController alloc]init]; window.rootVIEwController= IPadVIEwController1; [IPadVIEwController1 release]; } 总结

以上是内存溢出为你收集整理的使程序同时支持iphone和ipad全部内容,希望文章能够帮你解决使程序同时支持iphone和ipad所遇到的程序开发问题。

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

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

原文地址:https://www.54852.com/web/1088688.html

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

发表评论

登录后才能评论

评论列表(0条)

    保存