rotation of video hide videocontroller - ios

when i rotate a video from portrait to landscape then it opens in landscpae mode perfectly but hide video controller bar. code which i am using :
-(void) readyPlayer
{
mp = [[MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"abc" ofType:#"mp4"]]];
[[NSNotificationCenter defaultCenter] removeObserver:mp
name:MPMoviePlayerPlaybackDidFinishNotification
object:mp.moviePlayer];
// Register this class as an observer instead
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(movieFinishedCallback:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mp.moviePlayer];
// Set the modal transition style of your choice
mp.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
mp.moviePlayer.scalingMode = MPMovieScalingModeAspectFit;
for(UIView* subV in mp.moviePlayer.view.subviews) {
subV.backgroundColor = [UIColor clearColor];
}
mp.moviePlayer.fullscreen=YES;
[self.view addSubview:mp.view];
[mp.moviePlayer play];
}
- (void)deviceOrientationDidChange:(NSNotification *)notification {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
rotation = 0;
// Later we may handle the Orientation of Faceup to show a Map. For now let's ignore it.
if (orientation == UIDeviceOrientationPortrait) {
{
NSLog(#"portrait");
[mp.view setFrame:CGRectMake(0,0,screenWidth,screenHeight)];
rotation = 0;
mp.view.transform = CGAffineTransformMakeRotation(rotation);
}
}
else if (orientation != UIDeviceOrientationUnknown) {
//CGRect bounds = [[UIScreen mainScreen] bounds];
switch (orientation) {
case UIDeviceOrientationLandscapeLeft:
{
NSLog(#"Case 1");
[mp.view setFrame:CGRectMake(0,0,screenWidth,screenHeight)];
rotation = M_PI_2;
mp.view.transform = CGAffineTransformMakeRotation(rotation);
}
break;
case UIDeviceOrientationLandscapeRight:
{
NSLog(#"Case 2");
rotation = -M_PI_2;
[mp.view setFrame:CGRectMake(0,0,screenWidth,screenHeight)];
mp.view.transform = CGAffineTransformMakeRotation(rotation);
}
break;
case UIDeviceOrientationPortraitUpsideDown:
{
NSLog(#"Case 3");
rotation = -M_PI;
[mp.view setFrame:CGRectMake(0,0,screenWidth,screenHeight)];
mp.view.transform = CGAffineTransformMakeRotation(rotation);
}
break;
default:
break;
}
}
}
Please help.

If your application needs to support only portrait orientation and all the videos need to play in both orientations, do the steps.
1->Project file->Summary->SupportedOrientations -> tick yes for all orientation values.
2->In your root view Controller implement (BOOL)shouldAutorotate and return NO.

Related

Playing video in Landscape and portrait

I have my app in portrait mode.
When video player enters full screen mode, I want to play that video in both landscape and portrait orientation.
moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
[moviePlayer.view setAutoresizingMask:(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth)];
[moviePlayer setScalingMode:MPMovieScalingModeFill];
moviePlayer.view.frame = CGRectMake(0, 0, self.videoPlayerView.frame.size.width, self.videoPlayerView.frame.size.height);
[self.videoPlayerView addSubview:moviePlayer.view];
and I am playing it on one button.
For you question i would like to give the below Reference
Portrait video to landscape
and
Allow video on landscape with only-portrait app
Enable your Landscape Device Orientation in Deployment Info. Then, add these methods in your ViewController:
- (BOOL) shouldAutorotate {
return NO;
}
- (NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation {
return UIInterfaceOrientationPortrait;
}
Try to add a canvas view as superview to your player and apply transformation to the canvas view.
- (void)initialize{
self.canvas = [[UIView alloc] initWithFrame: self.view.bounds];
[self.view addSubview:self.canvas];
// init moviePlayer
moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
...
[self.canvas addSubview: moviePlayer.view];
// Add observers
...
[[NSNotificationCenter defaultCenter] addObserver: self
selector: #selector(deviceOrientationDidChange)
name: UIDeviceOrientationDidChangeNotification
object: nil];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
}
- (void)deviceOrientationDidChange{
// Apply rotation only in full screen mode
if (self.isFullScreen) {
UIDeviceOrientation currentOrientation = [UIDevice currentDevice].orientation;
[UIView animateWithDuration: 0.3
animations: ^{
CGAffineTransform transform = CGAffineTransformMakeRotation(0);
switch (orientation) {
case UIDeviceOrientationLandscapeLeft:
transform = CGAffineTransformMakeRotation(M_PI_2);
break;
case UIDeviceOrientationLandscapeRight:
transform = CGAffineTransformMakeRotation(M_PI + M_PI_2);
break;
default:
break;
};
self.canvas.transform = transform;
self.canvas.frame = self.canvas.superview.bounds;
}];
}
}

MPMoviePlayer fullscreen playback orientation change

I am developing an ios application with viewcontroller which has two subviews A) mpmoviecontroller and B) pageviewcontroller. if the player is not in full screen mode and I change orientation subviews alignment is ok (I handle orientation change and make new CGRects for subviews). When I switch my video mode to full screen, rotate to landscape and zoom out, my pageviewcontrollers view is gone out of the screen. Here is my code
- (void)viewDidLoad
{
[super viewDidLoad];
self.streamPlayer.controlStyle = MPMovieControlStyleDefault;
[self.view addSubview: self.streamPlayer.view];
[self.streamPlayer prepareToPlay];
NSURL *streamURL = [NSURL URLWithString:#"http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8"];
[self.streamPlayer setContentURL:streamURL];
[self.streamPlayer play];
self.pageViewController = [self.storyboard instantiateViewControllerWithIdentifier:#"PageViewController"];
[self setFramesForPotrait];
[self addChildViewController:_pageViewController];
[self.view addSubview:_pageViewController.view];
[self.pageViewController didMoveToParentViewController:self];
}
- (void)orientationChanged:(NSNotification *)notification
{
[self adjustViewsForOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
}
- (void) adjustViewsForOrientation:(UIInterfaceOrientation) orientation {
if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
{
[self setFramesForPotrait];
NSLog(#"%f",[[UIScreen mainScreen] bounds].size.height);
NSLog(#"%f",[[UIScreen mainScreen] bounds].size.width);
}
else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
[self setFramesForLandscapeMode];
// self.pageViewController.view.frame = self.pageViewContainterRect;
NSLog(#"%f",[[UIScreen mainScreen] bounds].size.height);
NSLog(#"%f",[[UIScreen mainScreen] bounds].size.width);
}
}
-(void)setFramesForPotrait
{
CGRect frame = [[UIScreen mainScreen] bounds];
_videoFrameRect = CGRectMake(0,_BAR_HEIGHT, frame.size.width,_VIDEO_HEIGHT_PORTRAIT);
_pageViewContainterRect = CGRectMake(frame.origin.x, _BAR_HEIGHT + _VIDEO_HEIGHT_PORTRAIT, frame.size.width, frame.size.height-_BAR_HEIGHT-_VIDEO_HEIGHT_PORTRAIT);
[self.pageViewController.view setFrame :self.pageViewContainterRect ];
[self.streamPlayer.view setFrame: _videoFrameRect];
}
-(void)setFramesForLandscaeMode
{
CGRect frame = [[UIScreen mainScreen] bounds];
_videoFrameRect = CGRectMake(0,_BAR_HEIGHT, frame.size.height/2,frame.size.width-_BAR_HEIGHT);
_pageViewContainterRect = CGRectMake(frame.size.height/2, _BAR_HEIGHT, frame.size.height/2,frame.size.width-_BAR_HEIGHT);
self.pageViewController.view.frame = self.pageViewContainterRect;
[self.streamPlayer.view setFrame: _videoFrameRect];
}

iPad resize UIView when keyboard is shown

I am running a phonegap application on iOS7 and I need to resize the UIView when the keyboard opens and when the orientation of the device changes.
I have some of the resize working but I am stuck when the orientation of the device is LandscapeRight, the first time the keyboard opens it slides up then the second time it slides it up even more.
I have search similar answers on stackoverflow and none have solved what I am looking for. So, please don't just copy and paste a solution from else where, thanks.
MainViewController.m
int screenWidth;
int screenHeight;
float keyboard_offset = 80.0;
- (void)viewWillAppear:(BOOL)animated
{
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardDidShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(keyboardDidHide:) name:UIKeyboardWillHideNotification object:nil];
CGRect viewBounds = [self.webView bounds];
viewBounds.origin.y = 20;
viewBounds.size.height = viewBounds.size.height - 20;
self.webView.frame = viewBounds;
self.webView.backgroundColor = [UIColor blackColor];
self.webView.opaque=NO;
screenWidth = self.view.frame.size.width;
screenHeight = self.view.frame.size.height;
}
[super viewWillAppear:animated];
}
- (void)orientationChange:(NSNotification *)note
{
UIDevice * device = note.object;
switch(device.orientation)
{
case UIDeviceOrientationLandscapeLeft:
[self.view setFrame: CGRectMake(-keyboard_offset, 0, screenWidth + keyboard_offset, screenHeight)];
break;
case UIDeviceOrientationLandscapeRight:
[self.view setFrame: CGRectMake(keyboard_offset, 0, screenWidth + keyboard_offset, screenHeight)];
break;
case UIDeviceOrientationPortrait:
case UIDeviceOrientationPortraitUpsideDown:
[self.view setFrame: CGRectMake(0, 0, screenWidth, screenHeight)];
break;
default:
break;
};
}
- (void)keyboardDidShow:(NSNotification *) notification
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(orientationChange:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeLeft)
{
[self.view setFrame: CGRectMake(-keyboard_offset, 0, screenWidth + keyboard_offset, screenHeight)];
}
else if([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationLandscapeRight)
{
[self.view setFrame: CGRectMake(keyboard_offset, 0, screenWidth + keyboard_offset, screenHeight)];
}
else
{
[self.view setFrame: CGRectMake(0, 0, screenWidth, screenHeight)];
}
}
- (void)keyboardDidHide:(NSNotification *) notification
{
[self.view setFrame: CGRectMake(0, 0, screenWidth, screenHeight)];
}
AppDelegate.m
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
/*
Orientation change for iOS7
*/
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification
object:[UIDevice currentDevice]];
self.window.clipsToBounds = YES;
[[UIApplication sharedApplication] setStatusBarStyle: UIStatusBarStyleBlackOpaque];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
/**
* Change the status bar color on orientation change.
*/
- (void) orientationChanged:(NSNotification *)note
{
UIDevice * device = note.object;
switch(device.orientation)
{
case UIDeviceOrientationLandscapeLeft:
self.window.frame = CGRectMake(-20, 0, screenWidth, screenHeight);
self.window.bounds = CGRectMake(-20, 0, screenWidth, screenHeight);
break;
case UIDeviceOrientationLandscapeRight:
self.window.frame = CGRectMake(20, 0, screenWidth, screenHeight);
self.window.bounds = CGRectMake(20, 0, screenWidth, screenHeight);
break;
case UIDeviceOrientationPortrait:
self.window.frame = CGRectMake(0, 20, screenWidth, screenHeight);
self.window.bounds = CGRectMake(0, 20, screenWidth, screenHeight);
break;
case UIDeviceOrientationPortraitUpsideDown:
self.window.frame = CGRectMake(0, -20, screenWidth, screenHeight);
self.window.bounds = CGRectMake(0, -20, screenWidth, screenHeight);
break;
default:
break;
};
}
CDVViewController.m
/*
Change the status bar color to the old style
*/
-(UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
- (void)viewDidLoad
{
[super viewDidLoad];
/*
Only perform these actions for iOS 7 or above
*/
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[self setNeedsStatusBarAppearanceUpdate];
}
}

Can't redraw the popover in correct place after changing the orientation of the device

I have a tabbar app in which I need to show a popover from the tabBarItem by clicking on it. So, I in my appDelegate:
- (BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController
{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
if (viewController == [self.objTabBarController.viewControllers objectAtIndex:2])
{
if (self.settingsPopover == nil) {
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main - iPad" bundle: nil];
SettingsViewController *settingsController = [mainStoryboard instantiateViewControllerWithIdentifier: #"SettingsPopover"];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:settingsController];
self.settingsPopover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
self.settingsPopover.delegate = self;
CGSize screenSize;
if ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortraitUpsideDown){
screenSize = CGSizeMake ([UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height);
} else {
screenSize = CGSizeMake ([UIScreen mainScreen].applicationFrame.size.height, [UIScreen mainScreen].applicationFrame.size.width);
}
NSLog(#"WIDTH = %f, HEIGHT = %f", screenSize.width, screenSize.height);
screenSize.height -= 50;
screenSize.width = screenSize.width / 2 + 105;
CGRect rect = CGRectMake(screenSize.width, screenSize.height, 1, 1);
[self.settingsPopover presentPopoverFromRect:rect inView:self.window.rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
} else {
[self.settingsPopover dismissPopoverAnimated:NO];
self.settingsPopover = nil;
}
return NO;
}
}
return YES;
}
So it displays correctly. But I need to redraw the popover after the change of the device orientation. For this purposes I made:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:#selector(handleDidChangeStatusBarOrientationNotification:)
name:UIApplicationDidChangeStatusBarOrientationNotification
object:nil];
}
- (void) handleDidChangeStatusBarOrientationNotification:(NSNotification *)notification;
{
if (self.settingsPopover)
{
CGSize screenSize;
if ([[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortrait || [[UIApplication sharedApplication] statusBarOrientation] == UIDeviceOrientationPortraitUpsideDown){
screenSize = CGSizeMake ([UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height);
} else{
screenSize = CGSizeMake ([UIScreen mainScreen].applicationFrame.size.height, [UIScreen mainScreen].applicationFrame.size.width);
}
NSLog(#"WIDTH = %f, HEIGHT = %f", screenSize.width, screenSize.height);
screenSize.height -= 50;
screenSize.width = screenSize.width / 2 + 105;
CGRect rect = CGRectMake(screenSize.width, screenSize.height, 1, 1);
[self.settingsPopover presentPopoverFromRect:rect inView:self.window.rootViewController.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
}
}
So, the NSLog shows the correct screenSize after the changing the orientation but the popover shows in incorrect place. Can anyone help me to solve this?
For that you have to close your Popover first and then show it again as I have done to solve my problem
In case anyone is looking for an answer in Swift 3...
1) Register for orientation change events.
NotificationCenter.default.addObserver(self, selector: #selector(screenRotated), name: NSNotification.Name.UIDeviceOrientationDidChange, object: nil)
2) Inside your view controller being presented as a popover...
func screenRotated() {
// Redraw the popover.
DispatchQueue.main.async {
self.preferredContentSize = CGSize(width: UIScreen.main.bounds.width, height: self.view.frame.height)
}
}

MPMoviePlayerController view not resizing

I'm working with an MPMoviePlayerController which renders its UIView to the right dimensions on landscape, but when rotating to portrait it is simply not resizing. I think it's parent UIView is the one not resizing. How can I set this up?
I followed the instructions that #Alex Reynolds mentions in UIView autoresizingmask not working for me. This showed me that the view does resize when rotated. I still have the problem that when the UIView for the UIViewController that holds the player is loaded, if the orientation of the device is landscape, they it renders to the right frame, but if the devise is on portrait by the time it is loaded it is not resized to it. With #Alex Reynolds' answer, all I have to do is rotate the device once and it will start resizing properly after that.
It is still bad that it won't resize the first time. Has this happened to anyone before? If so, any input is greatly appreciated.
Have you set the MPMoviePlayerController's view's autoresizingMask appropriately? Is its superview's autoresizesSubviews property set to YES? (and likewise, does this superview also resize when rotating? I like to set colourful background colours for my views during testing to verify that they resize correctly when autorotating.)
If it's still not working after checking those properties, you can always set the movie player's view's frame property manually. The super view's layoutSubviews method is generally the best place to do that, but if it's not a view you've manually subclassed, you can also do it in the view controller.
- (void)viewDidLoad
{
[super viewDidLoad];
[self play];
[[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
-(IBAction)dismiss:(id)sender
{
//[self.view removeFromSuperview];
_moviePlayer =nil;
[self dismissViewControllerAnimated:YES completion:nil];
}
// Do any additional setup after loading the view from its nib.
-(void)play
{
NSURL *url = [NSURL URLWithString:#"stringurlvideo"];
_moviePlayer = [[MPMoviePlayerController alloc]initWithContentURL:url];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayBackDidFinish:)
// name:MPMoviePlayerPlaybackDidFinishNotification
// object:_moviePlayer];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayBackDidFull:)
// name:MPMoviePlayerDidEnterFullscreenNotification
// object:_moviePlayer];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:#selector(moviePlayBackDidExit:)
// name:MPMoviePlayerDidExitFullscreenNotification
// object:_moviePlayer];
_moviePlayer.controlStyle = MPMovieControlStyleDefault;
_moviePlayer.shouldAutoplay = YES;
if([[UIScreen mainScreen] bounds].size.height==568)
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
}
else
{
[_moviePlayer.view setFrame:CGRectMake(0,150, 320, 200)];
}
[self.view addSubview:_moviePlayer.view];
//[_moviePlayer.view setCenter:self.view.center];
[_moviePlayer setFullscreen:YES animated:YES];
}
- (void) moviePlayBackDidFull:(NSNotification*)notification
{
}
-(void)moviePlayBackDidExit:(NSNotification*)notification
{
////[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
-(void)viewWillAppear:(BOOL)animated
{
/* if ([[UIApplication sharedApplication] statusBarOrientation] == UIInterfaceOrientationPortrait)
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
CGRect rect=[bar frame];
rect.size.width=self.view.frame.size.width;
[bar setFrame:rect];
}
else
{
CGRect rect=[bar frame];
rect.size.width=480;
[bar setFrame:rect];
[_moviePlayer.view setFrame:CGRectMake(0,44, 480, 320-44)];
}*/
}
- (void)moviePlayBackDidFinish:(NSNotification*)notification {
MPMoviePlayerController *player = [notification object];
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:player];
if ([player
respondsToSelector:#selector(setFullscreen:animated:)])
{
[player.view removeFromSuperview];
}
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(NSUInteger)supportedInterfaceOrientations
{
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (BOOL)shouldAutorotate
{
return YES;
}
/*- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}*/
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if(toInterfaceOrientation==UIInterfaceOrientationPortrait && toInterfaceOrientation!=UIInterfaceOrientationPortraitUpsideDown )
{
if([[UIScreen mainScreen] bounds].size.height==568)
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
}
else
{
[_moviePlayer.view setFrame:CGRectMake(0,150, 320, 200)];
}
CGRect rect=[bar frame];
rect.size.width=self.view.frame.size.width;
[bar setFrame:rect];
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation ==UIInterfaceOrientationLandscapeRight)
{
CGRect rect=[bar frame];
if([[UIScreen mainScreen] bounds].size.height==568)
{
rect.size.width=568;
}
else{
rect.size.width=480;
}
[bar setFrame:rect];
[_moviePlayer.view setFrame:CGRectMake(0,44, rect.size.width, 320-44)];
}
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
/* if(fromInterfaceOrientation==UIInterfaceOrientationPortrait && fromInterfaceOrientation!=UIInterfaceOrientationPortraitUpsideDown )
{
CGRect rect=[bar frame];
rect.size.width=568;
[bar setFrame:rect];
[_moviePlayer.view setFrame:CGRectMake(0,44, 480, 320-44)];
}
else
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
CGRect rect=[bar frame];
rect.size.width=self.view.frame.size.width;
[bar setFrame:rect];
}*/
}
- (void)didRotate:(NSNotification *)notification
{
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIInterfaceOrientationLandscapeLeft || orientation ==UIInterfaceOrientationLandscapeRight)
{
CGRect rect=[bar frame];
if([[UIScreen mainScreen] bounds].size.height==568)
{
rect.size.width=568;
}
else{
rect.size.width=480;
}
[bar setFrame:rect];
[_moviePlayer.view setFrame:CGRectMake(0,44, rect.size.width, 320-44)];
}
else if(orientation==UIInterfaceOrientationMaskPortrait && orientation!=UIDeviceOrientationPortraitUpsideDown)
{
if([[UIScreen mainScreen] bounds].size.height==568)
{
[_moviePlayer.view setFrame:CGRectMake(0,200, 320, 200)];
}
else
{
[_moviePlayer.view setFrame:CGRectMake(0,150, 320, 200)];
}
CGRect rect=[bar frame];
rect.size.width=self.view.frame.size.width;
[bar setFrame:rect];
}
}

Resources