我的应用程序为iPhone 5提供了额外的功能,并且为它创建了一个带有.xib的独立类。我想检测屏幕高度(除非可以获取设备ID /型号)并相应地加载不同的视图控制器。我试过这个:为iPhone加载不同的xib 5
- (IBAction)select:(id)sender {
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
if (screenHeight == 960) {
Selection *selectView =[[Selection alloc] initWithNibName:nil bundle:nil];
selectView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:selectView animated:YES];
}
else {
Selection_5 *selectView =[[Selection_5 alloc] initWithNibName:nil bundle:nil];
selectView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:selectView animated:YES];
}
}
Selection and Selection_5是两个不同的类,每个类都有不同的xib用于用户界面。
是的,它工作。我用浮screenHeight = [UIScreen mainScreen] .bounds.size.height –
这是帮你解决这个问题 http://stackoverflow.com/questions/13275144/how-to-make-xib-compatible-与iphone5和iPhone4设备/ 13283851#13283851 –