UIWebView: Media Player Rotates View Controller - ios

I'm encountering an issue while using a webview. My app is currently a portrait application, but when a media player loads in a webview within my app, the user can rotate the player, which rotates my view controller as well. I know I can get a notification for when the player comes up and disappears, but is there a way to prevent it from rotating the controller in the first place?
It doesn't seem like anyone has an answer. I have all of the standard "don't rotate unless if I tell you to" methods and plist values, but its still rotating. Its only when I load up a webview and the media player loads over it. If I rotate my device, the media player rotates along with it, which feels natural, but when I go back to the webview view controller, its rotated, which isn't good.

Add this key in your info.plist :
UISupportedInterfaceOrientations and set it to UIInterfaceOrientationPortrait

Ok, this a blind shot. I've used this trick to force the system to adjust to the required orientation, add this lines when the webview will appears, or when the player will disappear:
UIViewController *viewController = [[UIViewController alloc] init];
[self presentModalViewController:viewController animated:NO];
[self dismissModalViewControllerAnimated:NO];
Try in some of those methods, or in the didAppear or didDisappear if dosen't work. I know it look like rubbish, but sometimes works.

There doesn't seem to be a correct answer to this question.

Related

iAD - adBannerView rotation

In my iPad app that supports all the device orientation, I add an adBannerView to the main view.
So far so good. It works and the ad rotates as expected.
If I click on a particular ad this is visualized full-screen, and when I close it I get back to my app.
The problem is that if you rotate the device while you are visualizing the full-screen ad, this rotates correctly, but when you close it and come back to the app the view is not rotated.
How to solve this? Please help or I will destroy my iPad! ;-)
Basically, you want the
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
method to be called again...
To do that, when the user closes the iAd, simply execute:
UIViewController *correctOrientation = [[UIViewController alloc]init];
[self presentModalViewController:correctOrientation animated:NO];
[self dismissModalViewControllerAnimated:NO];

MPMoviePlayerController done button, Landscape orientation

I'm using simple MPMoviePlayerController. In portrait mode it is emmbedded into my layout. When I rotate my device I want it to go full screen. In full screen mode there is a done button but only thing it does is pausing the video. I want to dismiss modal view controller when the done button is tapped. How can I do this?
I've tried:
Putting a [UIColor clearColor] on a background of a button and place a button over Done button thus intercept touch event into my own selector. It failed because my custom button isn't displayed when MPMoviePlayerController is in fullscreen mode.
Going to notification center and trying to catch "willExitFullscreen" but it won't occur (pressing done button when in landscape fullscreen mode isn't goint out from the fullscreen mode).
Finding done button in the MPMoviePlayerController... but I was unable to find it.
Using MPMoviePlayerViewController isn't an option as I want to be able to use embedded player in my controller when i Portrait mode, and be able to rotate movie without loading it from scratch (so pushing new controller when user changes device orientation isn't right solution for me).
I've read a few topics on this issue and question can be the same or similar but anserws require either things I've checked (i.e. notifications) or things I can't use (MPMoviePlayerViewController).
ANSWER (as I am unable to post it in 7h)
Heh ok..
The culprit of this whole mess was this line of code
[self.mpPlayer setControlStyle:MPMovieControlStyleFullscreen];
So it seems that setting Fullscreen control style when going into fullscreen mode will break done button....
Makes no sense to me. But when I commented out this line I am able to recive willExitFullscreen notification and I can work with that.
The culprit of this whole mess was this line of code
[self.mpPlayer setControlStyle:MPMovieControlStyleFullscreen];
So it seems that setting Fullscreen control style when going into fullscreen mode will break done button....
Makes no sense to me. But when I commented out this line I am able to recive willExitFullscreen notification and I can work with that.

how can i make a custom, in-app camera for my iphone app developed in xcode?

i am making a photography iphone app and am after, upon the app being launched, the screen to be a large image where the camera is shown in the center through a hole in the picture - this should be a similar look to that of hipstamatic. since the camera would be open upon launch, i would also need a button to take the picture (but that is not a priority at the moment). i am wondering whether there is an easy way to do what i have described? so far, research has pointed me towards using the uiimagepickercontroller, but using just this did not give me nearly the amount of customization i am after - or am i mistaken and i can do as i described using the uiimagepickercontroller?
right now, this is the code i'm using for the camera - it's currently an ibaction linked to a button that launches the camera once clicked. however, as i mentioned, i would like the camera to open on its own upon opening the app
self.picker = [[UIImagePickerController alloc] init];
self.picker.allowsEditing = NO;
[self.picker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentModalViewController:self.picker animated:NO];
[picker release];
this code not only navigates away from the current view, but it has all the controls (zoom, tap to focus, etc.), is full screen, and plays that silly animation of the lens opening.
anything you have to offer would be greatly appreciated.
many thanks in advance
zach
Use the showsCameraControls and cameraOverlayView properties of UIImagePickerController to add custom overlay above the picker (using a view with a transparent background in which you add some elements as subviews to overlay / frame / mask some parts of the picker if needed.)
You can even use the cameraViewTransform to change the size and position (i.e. the transform) of the camera view that is capturing the camera image.

IOS4 UISplitViewController in Portrait Orientation with RootViewController showing like Landscape

In IOS 3.2 I was able to display my UISplitViewController side by side like in landscape mode.
In IOS 4.2 the RootViewController (MasterView) is not showing up in portrait mode. Does anyone know if we need to display the rootviewcontroll in a popover? Can we display it side by side like how it is in landscape mode?
I want to avoid having to click on a button to show the masterview (when in portrait mode)
In that case, you can skip the splitviewcontroller and create only view base application where you could manually control the UI.
on viewDidAppear you can do
[splitViewController setHidesMasterViewInPortrait:NO];
It works even though you get a warning. I think you can create category with a custom splitviewcontroller to get rid of the warning.
2.Otherwise you can do something like
on the viewWillAppear, you can do something like
if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
UIViewController *master = [[splitViewController.viewControllers objectAtIndex:0];
UIViewController *detail = [[splitViewController.viewControllers objectAtIndex:1];
[splitViewController setupPortraitMode:master detail:detail];
}
(setupPortraitMode ) http://intensedebate.com/profiles/fgrios.
I used setHidesMasterViewInPortrait:NO and it did work on the pre-5.0 releases, and even got into the apple store once. But the next time I updated the app, they rejected it because I used a hidden API. I am still searching for a way to make this work.

Screen blackout when performing Pinch Gesture on MPMoviePlayerController

I have this strange issue in iOS4 where in the Video which is playing in MPMoviePlayerController blacks out when the user performs certain kind of gestures over the screen. I'm simply creating a UIViewController and object for MPMoviePlayerController and then setting the View onto the UIViewController.
I want to ask if this issue is solvable or not, and whats the correct way of playing a streaming video on iPhone.
And if there is way that I can use a overlay view over MPMoviePlayerController and capture all gestures and pass on single taps or touches to MPMoviePlayerController for general functionality of MPMoviePlayerController and avoiding Gestures that is causing the issue.
Please help me solving the problem with the Best possible solution and please help me in elaborating the solution.
Apple embedded UIPinchGestureRecognizer in MPMoviePlayerViewController, but it can't be found in UIResponder.gestures property.
You can disable UIPinchGestureRecognizer embedded in touchesBegan method of MPMoviePlayerViewController.
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
NSArray *array = touch.gestureRecognizers;
for (UIGestureRecognizer *gesture in array) {
if (gesture.enabled && [gesture isMemberOfClass:[UIPinchGestureRecognizer class]]) {
gesture.enabled = NO;
}
}
}
}
I had a similar problem and I just found the reason of my problem from the Apple's doc:
When you add a movie player’s view to your app’s view hierarchy, be sure to size the frame correctly, as shown here:
...
[player.view setFrame: myView.bounds]; // player's frame must match parent's
...
Now my pinches are not crashing my app.
I saw this issue and found a simple workaround.
The above gesture-nuking trick could not be used as we do not want to use MPMoviePlayerViewController (we have some custom controls when the video is not in fullscreen and would like to keep the smooth transition).
Symptoms (iOS 5.1):
When the user repeatedly opened a video in fullscreen, pinched it back out of fullscreen and then did the same with a new video the screen would go black the 5th time a video was started and entered fullscreen.
While the screen is blacked out it is possible to hide and show the status bar by single tapping, but no video or navigation bar appears.
Using the "Done" button in fullscreen instead of pinch it was possible to close fullscreen without any problems ever.
We allocate a fresh MPMoviePlayerController for each video and don't leak anything. This did not help.
Workaround:
When dismissing the view which had the MPMoviePlayerController view in it we set contentURL = nil on the player.
After that we have no problems with black screen on subsequent MPMoviePlayerController instances.
It seems there is some internal cleanup which is performed when using the "Done" button, but not when pinching to close fullscreen.
I hate this issue. What I have been able to find is that having full screen mode needs to have embedded control in order for the NSNotificationCenter to respond with the correct Notification. Sounds stupid and ridiculous, but this is what i've found in 4.0.

Resources