Overlay MPMoviePlayer in full screen mode (iPad)

I want to add a button to my video player when it is playing in full screen mode. I created Overlay on my video player and it works great on the iPhone. I tried the same thing on the iPad, but the button never appears.

Here is my code:

 NSArray *windows = [[UIApplication sharedApplication] windows];
 if ([windows count] > 1){
       UIWindow * moviePlayerWindow = [windows objectAtIndex:1];
       NSArray * subviews = [moviePlayerWindow subviews];
       UIView * videoView = [subviews objectAtIndex:0];
       [videoView addSubview:myButton];
}

He's sewing how ipad dosen't creates a UIWindow for full screen mode.

Does anyone know how I can do this?

Thank!

+5
source share
2 answers

I found a solution to this problem a few weeks ago:

This method does not seem to work on the iPad (I have not tested the iPhone SDK 4>), so you can do the following to get around it.

UIWindow (, [[[[UIApplication sharedApplication] windows] objectAtIndex: 0] addSubView: myView]), .

, , , , willRotateToInterfaceOrientation .

+3

@tigermain .

[[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubView:myView]

, , .

- NSNotificationCenter, UIApplicationDidChangeStatusBarOrientationNotification.

    // assign a notification
    id center = [NSNotificationCenter defaultCenter];
    [center addObserver:self
             selector:@selector(didRotate:)
                 name:UIApplicationDidChangeStatusBarOrientationNotification
               object:nil];

    // this method will get called when the orientation changes
    -(void) didRotate:(NSNotification*)notification {

        UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
        NSLog(@"%d", orientation);
        // ... transform view accordingly to the enum 'UIInterfaceOrientationXXX'
    }
+2

All Articles