2013年7月30日 星期二

新增iPad.xib

1,新增YourView~ipad.xib
2,把File's Owner的Custom Class改為YourViewController。
3,最重要的一步:對File's Owner按右鍵,把view跟你剛新增的View做連結。
4,把原來view上的元件copy過來,把該有的連結拉回去YourViewController.h裡。
5,最後,把初始化的地方改為判斷目前device來選用你的View
這裡是用我寫好的singleton為例
static QFunViewController* instance = nil;
+ (QFunViewController*) shareInstance{
    if (instance == nil) {
       
        if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
            instance = [[QFunViewController alloc]initWithNibName:@"QFunViewController" bundle:nil];
        else
            instance = [[QFunViewController alloc]initWithNibName:@"QFunViewController~ipad" bundle:nil];
    }
    return instance;
}

沒有留言:

張貼留言