Par*_*iya 10 iphone xcode objective-c ios
在开发过程中universal apps,我们必须conditional code为每个人写一个device- iPad以及iPhone.在这种情况下,正确使用tilde可能是非常有益的.
例如,如果你想推送新的视图控制器,那么你必须编写很多代码行(差不多10行):
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@”MasterViewController_iphone” bundle:nil];
[self.navigationController pushViewController:masterViewController animated:YES];
[masterViewController release];
}
else
{
MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@”MasterViewController_ipad” bundle:nil];
[self.navigationController pushViewController:masterViewController animated:YES];
[masterViewController release];
}
Run Code Online (Sandbox Code Playgroud)
我们如何区分iphone和ipad的图像?
Par*_*iya 42
为了区分iPhone和iPad的XIB文件:
神奇的~将帮助你.您可以使用它来区分iPhone和iPad资产/ xib文件.
您的文件应以~iphone.xib 或结尾~ipad.xib.
注意:这是区分大小写不使用iPad或iPhone.
检查每个xib文件是否已连接所有插座并设置了正确的文件所有者.如果缺少一些,iOS可能决定不使用它们而是使用iPhone文件.
用于区分iphone和ipad的图像
特定于平台的修改器 - 使用修改器~iphone或~ipad指定针对特定设备大小的图像.
| 归档时间: |
|
| 查看次数: |
5019 次 |
| 最近记录: |