UIWebView - YouTube Video Landscape mode - iOS6 - iphone

I want to play a YouTube Video in a UIWebView in fullscreen (Landscape mode)
But all my other views to be only in Portrait mode. How is it possible that only the YouTube video is in landscape mode?
Do I have to enable the landscape mode in the app targets summary?
Thanks for help! :-)

If your app is using multiple orientations then you need to define them in the Project Target summary. e.g Portrait, Landscape left & Landscape right.
If you are having your device working for iOS5, use the following method(deprecated in iOS6) for rotating to particular orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
If you are having your device working on iOS6. you should use the following methods.
– shouldAutorotate – supportedInterfaceOrientations & – preferredInterfaceOrientationForPresentation
If your app supporting both versions then you could keep the both methods and check if your view controller is responding to the particular method by
if ([self respondsToSelector:#selector(methodToCheck)])

myTableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
CGAffineTransform rotate = CGAffineTransformMakeRotation(1.57079633);
[myTableView setTransform:rotate];
self.view = myTableView;
This will also work*
make sure here i have done in tableview

Related

rotate my iphone app in ipad when rotate option is enabled

I want to rotate my iphone application in ipad if I rotate the ipad
what I use in my code is :
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientation
{
return (orientation == UIInterfaceOrientationMaskAll);
}
and I check both portrait and landscape:
and the plist file:
my application device family is only iphone, and appears as an iphone in ipad device
But it doesn't rotate, please correct my code above, thank you
you ask it ? ;
if ([[UIDevice currentDevice] userInterfaceIdiom]==UIUserInterfaceIdiomPhone) {
}
Put it into the code if try again.
In the .plist file you only specify your startup orientations. After that every view controller can implement shouldAutorotateToInterfaceOrientation: in which the view controller is "asked" if a rotation to another orientation is acceptable. In the standard template for iPad apps this always returns YES and thus allows all orientations. In your case you might only return YES when the given orientation is UIInterfaceOrientationLandscapeLeft, although you should have a look if you can support both landscape orientations as Apple human interface guidelines strongly suggest to at least support both landscape orientations if one is supported.
Note that every view controller in your app has to specify its own orientations as it may make sense to have some views more restricted than others.
For further information on this have a look at:
Supporting orrientations for iPad apps: http://developer.apple.com/library/ios/#qa/qa1689/_index.html
Why won't my UIViewController rotate with the device: http://developer.apple.com/library/ios/#qa/qa1688/_index.html
UIViewController class reference: http://developer.apple.com/library/ios/#documentation/uikit/reference/UIViewController_Class/Reference/Reference.html

IOS 6 Storyboard rotation doesn't work as expected

I'm developing an iOS6 App with storyboards and i'm encountering an unexpected beahviour.
My app is almost in portrait mode , and i would keep this orientation in all the views except two.For this reason the project supports both landscape and portrait mode, i've subclassed navigation controller with a category (as explained almost everywhere :-)in Appdelegate.m and every view controller implements
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait; (landscape where needed)
}
and
-(BOOL)shouldAutorotate{
return YES;
}
Everything seems to work well except the fact that in the transition between a landscape view to a portrait one (not vice versa ?) , all the elements of the ui are displayed in landscape(imagine that you're keeping the phone horizontal), if you turn the phone , the rotation event is fired, the ui turns back in portrait and only now is locked to this orientation.Is there a way to fire the rotation BEFORE the view is presented?
Why the shouldAutorotate is not called at the ViewWillAppear stage?
Thank you!
Remove both the above function and try this it should work
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
Return YES for supported orientations
}
if still it's not working then try this change the appDelegate
[window addSubview:nav.view];
to this code
window.rootViewController=nav;
I found this online chapter very good for explaining UIViewControllers and rotation.
http://www.apeth.com/iOSBook/ch19.html#Rotation
It s a big page, scroll down to Rotation.

Appliction orientation changes to landscape if I stop a video in landscape

I am working on an application in which I have embedded an iframe on a screen to show the thumbnail of a video from vimeo.com. Every thing is working perfect but when I tap to play the video it invokes iPhone's DEFAULT MOVIE PLAYER and then I rotate my iPhone to landscape and video plays in landscape mode. But if video finishes in landscape mode then the screen (on which I have added the vimeo iframe) also gets rotated in landscape mode. I need to fix it in portrait only but video should play in portrait and landscape both modes.
Thanks!
Put this method in your all view controller to force them to remain always in portrait mode
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
When we play a video in this way then iPhone's in built video player get invoked that is of class "mpinlinevideoviewcontroller". We can't control it's functionality. So I set
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
in the view controller containing the web view and now only this screen of the application supports all orientation and thus my issue got removed (but not resolved).
one possible way is : When your player stopped playing just call this function.
-(void)setupOrientaion
{
[[UIDevice currentDevice] setOrientation:UIDeviceOrientationPortrait];
}
or else post your code here. it 'll be more helpful to analyze.

MPMoviePlayerViewController not playing in Landscape orientation under 5.1

Has anything changed in 5.1 which would affect how a MPMoviePlayerViewController works regarding device orientation?
I started getting reports from users today that videos were playing only in portrait mode. I figured out that they were using 5.1 and I quickly upgraded a device to recreate the situation. My code has not changed and works perfectly in 4.x, 5.0, and 5.01.
All the views in my app display in portrait mode except when a user clicks on a video, the movie player is suppose to take over the whole screen and launch into landscape more. The app using the 5.0 SDK but targeting 4.0. Here is the code I am using to display a video:
VideoPlayer *vp = [[VideoPlayer alloc] initWithContentURL:movieURL];
vp.moviePlayer.movieSourceType = src;
vp.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
vp.moviePlayer.shouldAutoplay = TRUE;
[self presentMoviePlayerViewControllerAnimated:vp];
VideoPlayer is a subclass of MPMoviePlayerViewController where the shouldAutorotateToInterfaceOrientation is overridden like so:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation == UIDeviceOrientationLandscapeLeft);
}
This pattern is recommended all over the internet and even by Apple. I don't understand why its not working under iOS 5.1 or why more people aren't complaining about this.
Any help will be greatly appreciated.
I had the same problem also - i was playing the movie on a opengl subview, (im making an interactive ebook in landscape mode so needed my movie - (in a uiview) to play in landscape also)
I corrected this by:
subclassing the open glview to a *viewcontroller then linking that *viewcontroller to the window
So while working with cocos2d i can now use all uikit in the correct orientation.
Sending all uikit views to my subclasses opengl view. (while making sure to add in my app delegate and checking that orientation is stated in plist too.)
"#if GAME_AUTOROTATION == kGameAutorotationUIViewController
[director setDeviceOrientation:kCCDeviceOrientationPortrait];
"#else
[director setDeviceOrientation:kCCDeviceOrientationLandscapeRight];
"#endif
hope this helps someone :) im very new at cocos2d so it took a while to figure out what i was doing wrong.
I had the same issue in iOS 5. The only way I was able to get it to work was to subclass MPMoviePlayerViewController.
#implementation MovieViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
return UIInterfaceOrientationIsLandscape(interfaceOrientation);
} else {
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
}
#end
It looks you have already tried to do this, but this block of code is working for me on the device with iOS 5.1. Not sure about the simulator.
I had a bunch of orientation issues after upgrading to iOS 5.1. For me, it was because the allowed orientations of sibling viewcontrollers up the chain resulted in no allowable orientation for a modal controller I was adding.
Do you have any cases in your view hierarchy where two subviews are added to a view? I was adding two subviews to my window in applicationDidFinishLaunching, and before iOS 5.1, they could have independent allowable orientations. ie, I could have one fixed in portrait orientation while the one on top rotated. Now, the other subview insists on portrait orientation.
My solution was to force the non-rotating view below:
[self.window insertSubview:self.nonRotatingViewController.view belowSubview:self.rotatingViewController.view];
This post helped me figure that out (and has some code):
iOS: Disable Autorotation for a Subview

Launching application in landscape orientation for IPad

Facing one issue with launching application in landscape orientation for IPad.
I have developed IPhone application which later I ported to IPad.
I have made setting regarding orientation in info.plist
[ UISupportedInterfaceOrientations~ipad ] to support all orientation UIInterfaceOrientationPortrait , UIInterfaceOrientationPortraitUpsideDown , UIInterfaceOrientationLandscapeLeft , UIInterfaceOrientationLandscapeRight.
but when I start IPad application in the landscape mode, it always start in the potrait mode.
Along this
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{ return YES; }
help me, if I am missing something with this..
Thanks,
Sagar
here's something I also discovered: setting the initial interface orientation in your info.plist is being ignored if you have Supported interface orientations set up with another orientation in the first slot! Put your initial orientation there as well - and the simulator will launch correctly, as will the app. this drove me nuts for a long time!
Put UISupportedInterfaceOrientations into your -Info.plist, with a setting for each orientation you support. This is used to see which orientation the app can start in. From there onwards it will ask your view controllers.
Sagar - I had the same issue but was able to resolve it.
Like yours, my app started as an iPhone app which I "upgraded" to a Universal app using the XCode wizard. I noticed that when running on the actual iPad, starting in landscape, the app would start in Portrait, then maybe rotate to Landscape. On the simulator, starting in landscape, the app would start in Landscape, then the simulator would rotate to Portrait.
On the iPad, my app is a split-view app with TabBarControllers on left and right. Each tab is a view controller that returns YES to shouldAutoRotateToInterfaceOrientation.
I noticed that a brand-new wizard-generated, simple-case with a splitviewcontroller, Universal app didn't have this problem.
The difference I found between my app and the simple-case was that I wasn't adding my splitview-controller's view to the app window in applicationDidFinishLaunchingWithOptions. Instead I was showing a "loading" view at this stage, then later when an initialization thread completed I'd add my splitviewcontroller's view (and hide the "loading" view).
When I added my splitviewcontroller's view to the app window during the call to applicationDidFinishLaunchingWithOptions everything started working fine.
There must be some magic that happens on return from applicationDidFinishLaunchingWithOptions???
Is your app similar to mine in that it isn't adding the main view controller's view to the window during applicationDidFinishLaunchingWithOptions?
As pointed out in a number of posts, you must set up the info.plist with both the supported and the initial interface orientations. However, the bigger issue is when does the initial orientation become effective? The answer is NOT when your view controller receives the "viewDidLoad" message. I found that on the iPad-1, running iOS 5.0, the requested initial orientation becomes effective only after several "shouldAutorotateToInterfaceOrientation"
messages are received.(This message passes the UIInterfaceOrientation parameter to the receiver.) Furthermore, even if the orientation says it is in Landscape mode, it may not be! The only way I found to be sure that the view is in Landscape mode is to test that the view height is less than the view width.
The strategy that worked for me was to lay out the subViews I wanted when the "viewDidLoad" message was received but to delay actually adding those subViews to the view until the controller received a valid "shouldAutorotate.." message with the orientation set to Landscape mode. The code looks something like:
(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
// N.B. Even when the interface orientation indicates landscape mode
// this may not really be true. So we insure this is so by testing
// that the height of the view is less than the width
if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
interfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
CGRect viewBounds = [[self view] bounds];
if ( viewBounds.size.height < viewBounds.size.width )
[self addMySubViews];
return YES;
}
else
return NO;
}
Apple has just released iOS 5.1, so this behavior may have changed. But I expect the code that is here should still work.