首页 > 开发 > iOS > 正文

1个viewController怎么关联2个XIB,一个是iphone的XIB,一个是ipad的xib

2017-09-08 14:03:56  来源:网友分享

简单的问题如题,给个思路啊

解决方案

if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {YourViewController *vc = [[[YourViewController alloc] initWithNibName:@"YourViewController_iPhone" bundle:nil] autorelease];}else{YourViewController *vc = [[[YourViewController alloc] initWithNibName:@"YourViewController_iPad" bundle:nil] autorelease];}