iOS app which runs on two screen (no mirroring)

前端 未结 2 537
猫巷女王i
猫巷女王i 2021-02-04 18:50

I\'ve created an iPad app which contains a slideshow and when this slideshow is tapped by the user he/she can entered some information.

What I\'d like to do now is to di

2条回答
  •  不要未来只要你来
    2021-02-04 19:04

    You can write the app to handle 2 UIScreens using Airplay and an Apple TV then set a seperate root view controller for both the TV UIScreen and for the iPad UIScreen. Then display the image or slideshow on the TV's view controller and run that from the events of you iPads view controller!

    AMENDED AFTER CLIFS COMMENT:

    So firstly in your app delegate in didFinishLaunchingWithOptions or didFinishLaunching setup a notification to receive the screen did connect.

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(screenDidConnect:) name:UIScreenDidConnectNotification object:nil];
    

    Then you need to keep a reference to your separate window and push controllers to it as you would any other window.

    - (void) myScreenInit:(UIScreen *)connectedScreen:(UIViewController*)mynewViewController
    {    
        //Intitialise TV Screen
       if(!windowTV)
        {
            CGRect frame = connectedScreen.bounds;
            windowTV = [[UIWindow alloc] initWithFrame:frame];
            windowTV.backgroundColor = [UIColor clearColor];
           [windowTV setScreen:connectedScreen];
            windowTV.hidden = NO;
        }
    
        UIViewController* release = windowTV.rootViewController;
        windowTV.rootViewController = mynewViewController;
        [release removeFromParentViewController];
        [release release];
    }
    
    - (void)setTvController:(UIViewController*)mynewViewController
    {     
        UIViewController* release = windowTV.rootViewController;
        windowTV.rootViewController = mynewViewController;
        [release removeFromParentViewController];
        [release release];
    }
    
    - (void)screenDidConnect:(NSNotification *)notification {
         [self myScreenInit:[notification object]];
    }
    

提交回复
热议问题