Trouble presenting Modal View Controller (MPMoviePlayerViewController) - iphone

My App starts up, and I have a UITabBarController. On the first tab I have a subclass of UIViewController. It's in this class that I have my movie playing functionality. I do not know why, but from this class, I cannot presentModalViewController or presentMoviePlayerViewControllerAnimated. I can however add views as a subView. I found this post, which is essentially what I'm trying to do (present a movie player view controller): How to present MPMoviePlayerViewController from a UITabBarController?
But even keeping a reference to the UITabBarController does not work for me. I'm not really sure why this class has problems presenting a modal view controller, versus in other tabs, I am able to. Any thoughts? Thanks.

After more looking, I found that the problem is I cannot present a view modally within the viewDidLoad method.

Related

Segue to a ViewController from non-Storyboard ViewController

Im using Storyboard for most screens in my iPhone app. However, I have one screen in my storyboard where I dynamically load a XIB an embedded it within the main view. This XIB have an image and some text and is connected to its own UIViewController.
My problem is that when I tap on the image in the XIB I want to segue to another UIViewController in my Storyboard. However, because my XIB is not in my Storyboard (its dynamically added at runtime) there is no way I can connect my XIB's view controller with a segue.
I'm getting the error "Receiver () has no segue with identifier". This makes sense because the segue is not connected so is there anyway tha tI can programmatically segue to the other view?
I've seen examples where I can have a modal transition, but instead I would like to have a "push" transition.
Thanks
Brian
I don't know if I really understand your question, but if you want a push transition, use this:
[self.navigationController pushViewController:someViewController animated:YES];

Memory issue in Present Modal View Controller

I am just presenting modal view controllers one after the another and not dismissing that. Because my requirement is such that I want show view controllers one after the another like chain.
1) Will this create memory problem ?
2) If so what is the work around ?
Thanx in advance
Yes you may get a memory or performance problem. I don't think Apple intended/intends for anyone to present multiple modal view controllers one after the other.
Have you seen this : Problem dismissing multiple modal view controllers
I think you should dismiss the current modal before presenting a new one. Always. Always. Always. You don't have to dismiss them animated though, you can dismiss them without animation so you don't see them disappear visually.
If you need to be able to go backwards through the chain of modally presented view controllers then I would instigate a method for doing this. e.g. add properties to your UIViewController subclasses that specify the next and previous viewController (or maintain a history trail of the viewControllers).
To be honest, it sounds like you should be using a navigationController and not presenting the viewControllers modally.

Understanding View Controllers

I have an TabBar application with 4 tabs. All four tabs have navigation controllers. In the settings tab i have a table with a cell for "Feedback". When the cell is clicked a FeedBackView controller is pushed which contains a feedback form with a few fields. This has a textfield for Category. When the textfield is touched, a modal view controller (FeedBackModalView) is presented with a picker. In the viewDidLoad method of the FeedBackModalView controller I typed NSLog(#"%#", self.parentViewController). In the console it shows the parentViewController as TabBar controller. Why is that? Shouldn't it be showing the FeedBackView controller as the parentView since I'm presenting the modal view in that controller?
I hope i was clear.
Using presentModalViewController with UITabBarController has some issues, and I believe the internal behavior of the method has kept changing in recent SDK versions. The bottom line is, you are supposed to use the root view controller to modally present a view controller. In case you are using tab bar interface, that becomes the UITabBarController object.
In an old version of SDK, when I presented a modal view in a view controller inside a tab bar controller the modal view did not appear in full screen, which wasn't an expected or a documented behavior. Now a modal view seems to appear in full screen anywhere, and I wouldn't be surprised if [self presentModalViewController:animated:] method internally checks self and if it has non-nil parentViewController property, send the message to the parent view controller (which will explain your observation).
My memory is vague and perhaps somebody has to correct me. However, I still believe it's the straightforward thing to understand (and also maybe practice) presentModal... only works with the root view controller.

Creating an overlay view ontop of EAGLView

I am creating a game using OpenGLES.
Game consists of a view controller and the EAGLView.
I have created another view controller that I want to handle the extra view that go ontop of the EAGLView so things like menu and options.
I have a call from the EAGLView view controller to the extra view controller that adds an IBOUTLET UIView to the appdelegates window however its not appearing. The methods being called but no view is being added.
Probably a really easy and stupid question but I cant work it out.
Thanks for any help in advance
Ok I have done it a different way.
I use a view Controller called GameViewController to load up and i add its subview to the window in the appDelegates applicationDidFinishLaunching method
Then i call a method to add another view controllers view (my open gl view) to the subview. This means I can then put other views over the top.
I don't know why i didn't do this before to be honest
Thanks for your help
Can you be more specific with this sentence:
I have a call from the EAGLView view controller to the extra view controller that adds an IBOUTLET UIView to the appdelegates window however its not appearing.
One approach is to use navigation controller that could be initalized with EAGLView controller as root. So, you can push and pop in navigation controller another view controller that handles the game menus.
Another approach is to present menu as modal view controller. This can be invoked with presentModalViewController: in current EAGLView controller.

Accessing UIViewController from UITableViewController?

In iOS4, I want to use MPMoviePlayerController. I have a UIViewController that I pass to a custom class that manages MPMoviePlayerController. That plays video fine.
I have another view that is a UITableViewController. Passing the UITableViewController to my UIViewController property on the video class doesn't work. I just get sound. I'm fairly sure this is because the UITableViewController needs to be a UIViewController. I can change the UITableViewController to a UIViewController but this is a fairly good rewrite. Is there a way to access the parent UIViewController behind the UITableViewController?
I have also tried
(UIViewController*)self;
but that doesn't work either. I just get sound again.
You can use `self.parentViewController. From the documentation:
Parent view controllers are relevant
in navigation, tab bar, and modal view
controller hierarchies. In each of
these hierarchies, the parent is the
object responsible for displaying the
current view controller. If you are
using a view controller as a
standalone object—that is, not as part
of a view controller hierarchy—the
value in this property is nil.