【问题标题】:Second UIScreen causing problems with UIStoryboards第二个 UIScreen 导致 UIStoryboards 出现问题
【发布时间】:2013-10-17 16:33:51
【问题描述】:

在我的应用程序委托中,我设置了另一个屏幕(用于 airPlay)。

当我创建第二个窗口并将第二个屏幕分配给它并运行应用程序时,我的故事板中的 TableView 会变成黑色。好像 tableView 没有正确渲染。我已将问题隔离到:

self.HDTVwindow.screen=[[UIScreen 屏幕] objectAtIndex:1];

HDTVWindow 是我的 airplay 应用程序的第二个窗口。当我注释掉这段代码时,情节提要运行良好,我的 UITableView 又漂亮又白。我是否通过在 appDelegate 中创建两个 UIWindows 来混淆故事板,即使它们被分配到不同的屏幕??

对于我的 appDelegate,请参见下文。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    if ([[UIScreen screens] count]>1)
        {
            CGRect frame = [[UIScreen screens]objectAtIndex:1].bounds;
            self.HDTVwindow = [[UIWindow alloc] initWithFrame:frame];

            UIImage* astonLogo=[UIImage imageNamed:@"AstonUni720p.png"];
            UIImageView* astonLogoView=[[UIImageView alloc] initWithImage:astonLogo];
            astonLogoView.frame=frame;
            [self.HDTVwindow addSubview:astonLogoView];

            self.HDTVwindow.hidden = NO;
            self.HDTVwindow.screen=[[UIScreen screens] objectAtIndex:1];//PROBLEM!!

        }

// Set Up Storyboard
   UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
   UIViewController *mainViewController = [storyboard    instantiateInitialViewController]; 
   self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
   self.window.rootViewController = mainViewController;
   [self.window makeKeyAndVisible];

 return YES;

}

【问题讨论】:

    标签: ios7 uistoryboard multiple-monitors uiscreen


    【解决方案1】:

    在 iPad 和 Apple TV 上运行时问题消失,看来模拟器中可能存在错误。以后我会一直在真正的 ios 设备上运行我的代码。

    【讨论】:

      猜你喜欢
      • 2014-12-12
      • 1970-01-01
      • 2022-08-18
      • 2015-09-07
      • 2012-11-01
      • 2011-05-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多