سؤال

In my app delegate i set up another screen (for airPlay).

When i create a second window and assign the Second screen to it and run the app the TableView in my storyboard turns to a black colour. Its as if the tableView is not rendering correctly. I have isolated the problem to :

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

where the HDTVWindow is the second window for my airplay app. When i comment out this code the storyboard runs fine and my UITableView is nice and white. Am i confusing the storyboard by making two UIWindows in the appDelegate, even though they are assigned to different screens??

For my appDelegate see below.

- (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;

}

هل كانت مفيدة؟

المحلول

The problem disapears when ran with the iPad and an apple TV, it seems there might a bug in the simulator. In future i shall always run my code on real ios devices.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top