I am calling a youtube channel on a UIWebView. When user selects a video, device launches its video player as normal. However, when video ends or user finishes it returning to view, an offset is applied to whole app!! All views have an offset on top but this only happens on iPad and iPad simulator with compatibility mode, on iPhone and iPhone simulator not! How to solve it? Thank you.
Problem is that status bar dissapears after video execution.
[[UIApplication sharedApplication] setStatusBarHidden:NO]; problem is beeing solved when an event is fired using NSNotificationCenter
Related
I used MPMoviePlayerViewController to play a video and when back to app, I need app force return portrait
I think the best way to solve this is by using
https://stackoverflow.com/a/13800907/620197
These are callbacks who only gets called when the user autorotates - you can tell the user to rotate the device and then the autorotate callback will be called and will show only the supported orientation.
If you still want force rotation i believe you need to dismiss the controller - try this and please do tell me if it worked out for you:
IOS 6 force device orientation to landscape
I have searched the web for a long time for a force rotation solution that will please me with no success, it almost looks like apple
Doesnt want us to be able to so this.
I've noticed that when my iPhone app enters the foreground after being suspended on an iPad2 (iOS version 4.3.3), the iPhone screen seems to shift up by a small amount after a split second. My understanding is that iOS takes a snapshot of the screen before suspending the app so it can quickly bring it back up when resuming, but it's not clear to me why it would be shifted. The status bar placeholder and iPhone image don't shift up, only the rest of the iPhone screen does. I don't see this problem in the 5.0 simulator.
Any ideas what's going on or how to fix this? Thanks
When the app loads, it displays the default.png file that you have in your app bundle. If you have this image the same as whatever the first screen of your app is (which apple suggests that you should do) then it is displaying this image, and then the actual screen once the app is done initializing. You can edit the png file by shifting up a pixel or two (you'll just have to guess and check to see exactly what you need).
The other possibility is that your default.png isnt the right size, so it is being resized when the app actually starts. Check that the dimensions are correct for the device you are testing on.
Setting the status bat to initially hidden caused this for me.
Status bar is initially hidden YES
This fixed it
- (void) setStatusBarVisible: (NSTimer *)timer
{
[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:#selector(setStatusBarVisible:) userInfo:nil repeats:NO];
}
It appears that setting then reseting (after a short delay) the status bar addresses this issue.
This fixes it but it shouldn't happen in the first place.
yes it happens when you come again to foreground. it happens with me & i have solved this issue by using
(void)layoutSubviews
that means i draws the things in layoutSubviews method which shifts & it works fine.
for more information on this check my problem & solution
In one View Controller ViewController1, I have tried to open a You tube video embedded in a UIWebview. It opens in the Movie Player window and then I use the "Done" button to come out of the movie player window. Again in another view controller ViewController2 in the same application, I open a MPMoviePlayerController(MPMoviePlayerController *audioplayer) to play an audio file using streaming. However, it remains in the paused state on opening the player. Even when i call the method [audioplayer play], the application automatically sets back the playback state to paused (i rechecked and it is not done through my code).
But if i reopen the application and in view controller ViewController2 i play the audio alone, then MPMoviePlayerController *audioplayer plays successfully.
Any idea what i might be doing wrong ?
This issue was found to be specific only to ios4.0.
This issue doesnt occur in ios4.1 and above.
This is a follow-on from: Overlay on top of Streaming MPMoviePlayerController
I've seen the various threads about checking for a new Window and then using that to apply my custom views to my fullscreen video however in SDK 4.1 this doesnt appear to be the case.
I have tried a timer and listening for UIWindowDidBecomeKeyNotification but in neither case does [[UIApplication sharedApplication] windows] ever contain more than 1 item.
I have tried adding my view to the players view property which works fine when displayed in place, but not when fullscreen, even if I add it in moviePlayBackDidEnterFullScreen event
I found a solution to this problem a few weeks ago:
It seems this method does not work on the iPad (I havent checked iPhone SDK 4>) so in order to get round it you can do the following.
After adding your video and setting to fullscreen you can add your controls directly to the UIWindow (e.g. [[[[UIApplication sharedApplication] windows] objectAtIndex:0] addSubView:myView]), they will then appear on top of your video video.
The only problem I have found with this is that they don't obey the orientation rules of the view and I have manually had to program the rotation code in the willRotateToInterfaceOrientation method of the view.
Issue summary
Changing the orientation of an iPad device or simulator while playing a video using MPMoviePlayerViewController results in an inconsistent rotation state upon dismissal of the video player. This is a known bug in iPad SDK 3.2, documented at http://www.openradar.me/8012810
Sample project
I have prepared a minimal sample project using the View-based Application template from Xcode 3.2.2, using the following code to launch the player
NSURL *movieUrl = [NSURL URLWithString:#"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:movieUrl];
[self presentMoviePlayerViewControllerAnimated:player];
[player release];
The code is available on GitHub at http://github.com/adamalex/FullScreenMovie or direct download using http://github.com/adamalex/FullScreenMovie/zipball/master
Steps to reproduce
Obtain the project using the information above
Launch the project with the iPad simulator or device
Tap the button to begin playing the video
Rotate the iPad by 90 degrees
Dismiss the video
Note the UIStatusBar is out of sync with the application UI
Objective
I have contacted Apple and they have confirmed this is a bug that is being investigated. I would like to discuss temporary workarounds that use public APIs safe for submission to the App Store. I am going to open a developer support case with Apple as well and will report back with my own progress.
Successful response from Apple Developer Technical Support!
This is a known bug and a we're received a number of duplicate bug reports and so iOS engineering is aware of the issue and we do have a temporary workaround as suggested by iOS engineering.
You will need to implement this in the view controller which presents the movie player.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[self performSelector:#selector(fixStatusBar) withObject:nil afterDelay:0];
}
- (void)fixStatusBar {
[[UIApplication sharedApplication] setStatusBarOrientation:[self interfaceOrientation] animated:NO];
}
While this is somewhat ugly, it should fix the issue for now. It would be recommended to remove this code once the bug is fixed in the system.
This took care of the issue completely for me, and you can revisit http://github.com/adamalex/FullScreenMovie for the code with the fix applied.
This also solves an iPhone/iPodTouch rotation issue that I was struggling with. I am developing a universal app in which each view displays a different image depending on whether the device is in portrait or landscape orientation. Buttons are used to navigate between views.
If the app is running on the device and a portrait view is rotated to landscape, my image switching takes place. If the device is then placed flat on a table top and the button is tapped to display the next view, the view appears in landscape but shows the portrait image instead. I solved the problem by forcing a portrait view to appear by detecting for face up and down, but Apple's code solved this problem (as well as the similar movie problem I was also experiencing).
Many thanks for reporting the bug - I assumed it was just my bad coding...