Ứng dụng của tôi có thêm chức năng cho iPhone 5 và tôi đã tạo một lớp riêng biệt với một .xib cho nó. Tôi muốn phát hiện chiều cao màn hình (trừ khi có thể lấy ID/mẫu thiết bị) và tải một trình điều khiển chế độ xem khác nhau cho phù hợp. Tôi đã thử điều này:Tải một xib khác cho iPhone 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];
}
}
Lựa chọn và lựa chọn_5 là hai lớp khác nhau, mỗi lớp có giao diện người dùng khác nhau.
Có, nó hoạt động. Tôi đã sử dụng float screenHeight = [UIScreen mainScreen] .bounds.size.height –
điều này giúp bạn giải quyết vấn đề này http://stackoverflow.com/questions/13275144/how-to-make-xib-compatible- with-both-iphone-5-and-iphone-4-devices/13283851 # 13283851 –