Entering full screen in MPMoviePlayerController calls viewWillDisappear and viewDidDisappear - mpmovieplayercontroller

To play video in my app, I set MPMoviePlayerController and add it to subview. The user can change to full screen mode using pinch gesture.
In this viewController (that contains the Movie Player View), I set the viewWillDisappear to set objects to nil.
But, in iOS 6, when activating fullscreen mode the MPMoviePlayerController in the view controller that contains the Movie Player View calls the methods viewWillDisappear and viewDidDisappear.
In iOS5, those methods were not called.

I came across this issue as well and it caused me a lot of headache. My temporary solution until the bug is fixed is to check the player's fullscreen Boolean value in viewWillDisappear: and/or viewDidDisappear:. If it returns YES, the movie is entering fullscreen mode and you should refrain from doing anything that might interrupt it.

To everyone has noticed that and having problem with this, I found this report in community Open Radar: http://openradar.appspot.com/12327997

I am not sure this is a question but in case someone has a problem with the issue herein stated, that is, someone using a viewController (that contains the Movie Player View), I found the solution:
I was using a view controller with the Movie Player Controller and then presented this view controller as a subview. I just got rid of it and used the MoviePlayer.view as a subview directly and it works just fine.
Not a problem with iOS 5, but now, it is. Fix it and enjoy!

Related

Trying to Change my ViewController to full screen but can't

I know there are many questions and answers about how to make a ViewController full screen. My problem is little odd. I am not using Navigation Bar and when I try to set my modalPresentationStyle to fullScreen my View is showing and than hiding.
This is probably due to code you have not shown us, such as a bad viewWillDisappear in the previous (select place to ride) view controller.
You didn't experience the issue before because a presented view controller that isn't full screen doesn't cause the previous view controller to disappear.

UITableviewcell width not filling the screen

I don't know if this is a bug with AutoLayout or Xcode but I've realised that if I run my application on a device which isn't the same size as the device in my storyboard, the elements are adopting the incorrect size.
I.e. Selecting View as iPhone SE and running the application on an iPhone 7+ The size of my tableview is the width of an iPhone SE screen, this fixes itself when I reload the view and then it then adopts the width of the iPhone 7+ screen.
Just a note as well the table view doesn't have a fixed width and is pinned to the top, bottom, left and right with 0 spacing and also I'm changing the height of the cells programmatically in code if this could affect it at all as well.
Video: https://drive.google.com/open?id=0B0QLbDLfJn6_YzljUGg4RTUwaTg
Views that come from a xib (or storyboard) have their IB frame values when they are created, before they are added to the view hierarchy. So a case like you describe is probably that something is accessing a view loaded from a xib before it has become part of the layout process and resized.
This would also explain why it's fixed when you go away and come back. The first time, it got the values before they were final, but the second time the values are already final and correct.
Layout code called fromviewDidLoad() for view controllers, or awakeFromNib() or initWith(coder:) for views is the likely cause. Layout code called from viewDidLoad() is especially problematic because it was fine up to iPhone 5s, but would now cause this problem.
It's impossible to say what exactly the issue just from this. From the NSLog statements visible in the video, the issue is whatever code calls that "weather view width". That is being called too early in the layout process. It needs to go in viewWillAppear or viewWillLayoutSubviews to make sure the correct values are ready for whatever calculation is dependent on that. Hope this helps.
I can't seem to recreate this. I would recommend double checking for any updates for Xcode and the Developer tools (softwareupdate --install -a).
Incase you haven't, restart Xcode.
EDIT: Disregard this answer, please read Mike Sand's post.
Try self.view.layoutIfNeeded in viewDidLoad or in viewWillAppear

XCODE play video from TableViewCell

I am using storyboards in XCODE4.
I am currently able to launch a video from a table cell using a push segue from a tableview controller to a viewcontroller. When the segue gets called, the view controller immediately launches the video using standard media player code in viewdidload. My problem is once the video is over, the app doesn't return to the table cell, instead it stays at the blank table view controller until a user clicks "Back".
Anyone know a simple way to have the video end and switch back to the TableViewController?
Apple didn't make this one easy. My assumption is that they want the user to choose to exit the movie player when s/he feels comfortable enough to do it (and then the user would have the choice to replay or skip back to parts that they might want to see again).
But one way to catch the end of the movie happening would be to register for the "MPMoviePlayerPlaybackDidFinishNotification" notification (documentation linked for you) and then exit and/or remove the MPMoviePlayerController.
Note: this notification also fires if there's any error while loading the movie (see the documentation for initWithContentURL:).

xcode two uitabbarcontrollers one page. auto-rotate issue

Summery:
I have a custom UITabBarAutoRotateController which returns YES from shouldAutorotateToInterfaceOrientation. This has no effect.
If I minimize and show the app again, the rotation issue goes away.
How do I refresh the screen so the user does not have to do this (so rotation works again)?
Details (setup graphically, so no code):
I have two UITabBarController in MainWindow.xib. I only want one to show at a time. So I am linking graphically rootViewController = tabBarController_name1. There is also tabBarController_name2.
I will also have an alert MessageBox for a user to choose what type of application they need, and it will choose a tab bar controller based on their request (per customer definition). This is commented out for now.
There is a bug with Rotation when two UITabBarControllers exist on the same xib. When I try to rotate the screen, it stays upward with wherever the main screen button (power button looking button) faces. HandleOrientationChange does not get called on the active custom ViewController being shown.
The reason I believe it's a bug is because if I hit the main screen button (minimizing the application), and click back on the application (brings it back to the foreground), rotation works perfectly!
Sorry for making you read all that mumbo :). My true question is, "Is there anyway I could refresh the main window or likewise UITabBarController's to get rotation working (without requiring the program be minimized and shown)"? A work-around, if you will?
p.s. I cannot use Storyboard for backwards compatibility reasons. The customer will be receiving this code/project. So I would like to keep this in one graphical page, rather than hiding/showing UITabBarItem's.
EDIT: two-uitabbarcontrollers-and-autorotation and uitabbarcontrollers-and-uinavigationcontrollers were both helpful, but did not address "why" this issue happens. "noob" here when it comes to xcode :)
Tab bar controller inside a navigation controller, or sharing a navigation root view is the answer. Do not use a TabBarViewController. Which, as a noob, I'm not quite sure why TabBarViewController exists (or at least isn't depreciated).
Dragging two TabBarViewControllers into the same page should result in a warning saying that you probably want to implement TabBarViewController by making a custom UIViewController and attaching a plain UITabBar to it.
Frustrating...but finally making progress :)

NSOutlineView - scroll to top at launch

Got an NSOutlineView that is configured in the controller's awakeFromNib, with a datasource and autosaved expanded nodes.
All working like a charm.
The problem is that somewhere, somebody is saving the state of the scroll position, too.
This means that at launch of the app, the outline view can appear scrolled to the bottom - if that was how the user left it last (this is on Lion if it matters).
What is the best way to open the app with the outline view scrolled to the top? Preferably in awakeFromNib, or at least so the user won't be seeing a scroll movement.
I recently started having problems with my NSOutlineView being scrolled down (so that I couldn't see my elements until I scrolled up), and I used this method :
In my applicationDidLaunch: method I use this :
[outlineView scrollPoint:NSMakePoint(0.0f, [outlineView frame].size.height)];
And it seems to work. (I also had the same problem on an IKImageBrowserView, and the same piece of code worked on that too)
Hope this solution suites you better ^^
What about [outlineView scrollToVisible:0]; ?

Resources