繁体   English   中英

在iPad(不是iPhone)上的iOS黑屏

[英]iOS black screen on ipad, not iphone

我有一个问题要坚持几个小时。

我拥有一部iPhone,它成功地进入了App Store。 现在,我希望它也支持iPad。

为了实现这一目的,我为iPad创建了新的XIB文件,将其命名为:

iPhone:RootViewController_iPhone.xib

iPad:RootViewController_iPad.xib

然后我适当地设置文件的所有者。

这就是我所说的:

MyViewController *vC;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
    vC = [[[MyViewController alloc] initWithNibName:@"MyViewController_iPhone" bundle:[NSBundle mainBundle]] autorelease];
} else {
    vC = [[[MyViewController alloc] initWithNibName:@"MyViewController_iPad" bundle:[NSBundle mainBundle]] autorelease];
}

然后,根据当前设备系列,在每个ViewController中进行一些自定义layoutfix。

这对于我的所有观点(除其中两个观点)都适用。 无论我尝试了什么,屏幕都保持黑屏。 我检查了thisthisthis ,仅列出了几个问题。 显然我无法解决此问题。

有什么想法为什么只对我的两种观点如此?

提前致谢。

编辑:这是一些初始化代码:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{

    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        NSLog(@"frame: %@", NSStringFromCGRect(self.view.frame));    //frame: {{0, 0}, {768, 1004}}
        self.view.backgroundColor = [UIColor groupTableViewBackgroundColor];     //no result here
    }
    return self;
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    UILabel *l1 = [[UILabel alloc] initWithFrame:CGRectMake(50, 50, 100, 30)];
    l1.backgroundColor = [UIColor clearColor];
    l1.text = @"Zurück";
    l1.textColor = [UIColor blackColor];
    l1.textAlignment = UITextAlignmentCenter;
    l1.font = [UIFont fontWithName:@"Helvetica" size:10];
    [self.view addSubview:l1];
    [l1 release];
}

我建议这样做(不要让捆绑为零)

initWithNibName:@"RooViewController_iPad" bundle:[NSBundle mainBundle]] autorelease];

好吧,我不知道是否有帮助...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM