
概述在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所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
评论列表(0条)