刚看到一段代码,关于自适应iphone、ipad布局的,有点启发,记载一下
- (id)init
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
[super initWithNibName:@"MainView~ipad" bundle:nil];
} else {
[super initWithNibName:@"MainView" bundle:nil];
}
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(screenDidConnectNotification:) name: UIScreenDidConnectNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(screenDidDisconnectNotification:) name: UIScreenDidDisconnectNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(screenModeDidChangeNotification:) name: UIScreenModeDidChangeNotification object: nil];
return self;
}
- (id)initWithNibName:(NSString *)n bundle:(NSBundle *)b
{
return [self init];
}