0

我是一个通用应用程序,如何以编程方式创建和加载 nib 文件?如何连接新 nib 文件中的对象插座?或者每次我必须检查设备是 iPhone 还是 iPad 并相应地放置对象?

4

1 回答 1

0

You need to create separate xib for iPhone and iPad, like- ViewA, ViewA~iPad and you have to load conditionally-

ViewA *myView;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
     myView = [[ViewA alloc] initWithNibName:@"ViewA" bundle:nil];
}
else {
    myView = [[ViewA alloc] initWithNibName:@"ViewA~iPad" bundle:nil];
}

If you want to create some view programatically, then you have to deal with their frames using the same if-else conditions.

于 2012-05-09T11:56:11.203 回答