When I open some other view controller from my main view controller, the some other view controller gets opened with no issues. But when I dismiss other view controller and coming back to my view controller, the status bar overlaps my main view controller.
Size of our view is 460 and 20 pixels for status bar is given.
Similar question is already posted in stack overflow, there is an answer to that question which says "The solution was to load the UIViewController in the old UINavigationViewController. This way the UIViewController keeps its former position.". But we are not using UINavigationViewController. Can any one please tell us how else we can solve this issue.
If your main view controller is created in Interface Builder, go check the Inspector window and make sure that "wants full screen" is not enabled. Do the same for any other view controllers.
I haven't personally encountered this, but if you're flipping views around you probably want to do what UITabViewController and UINavigationController do and create one view that serves as a container for other views that you switch between.
Sometimes which "simulated user interface elements" you have enabled for a view will affect the placement of the view, so make sure that the simulated UI elements for all views match what you would actually be looking at when the view is shown.
If you're not using presentModalViewController to show "some other view" then give that a try.
Related
I have an iphone app consisting of a tabbar controller in the main.xib, where the tab bar controller contains navigation controllers, which are associated with corresponding view controllers. I assume this is pretty standard.
If I present a modal view controllers view from a navigation controller contained in this hierarchy, the view owned by this view controller pops up as you would expect. However, Ive noticed if I have controls (such as a button) at the very bottom of this 'modally presented' view it is rarely detecting taps. It seems as though the tabset underneath is blocking the touches. Note that when I present the modal view controllers view it fills the visible screen, it isn't sliding up from underneath the tab set.
I thought this tababar controller->navigation controller hierarchy was pretty standard, shouldn't I be able to present a modal view controller from a navigation controller in this set up without issue? I have also tried to present the modal view controller from the tab bar controller, with the same effect.
How do I present a modal view controller in an app with the tabbar controller->navigation controller hierarchy such that the lowest portion of that view can detect touches?
thanks for any help!
Check out the first answer by Harry, I believe this set-up is related to your situation. Post an update and let us know if this helps: UIView doesn't resize to full screen when hiding the nav bar & tab bar
Also, what code are you using to present the modal view?
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.
I am facing few problems while using tabBar with navigation controllers.Each tabBar item is associated with a separate navigation controller.Problems are listed as follows:
1.There are more than five tabBar items in my tabBar so a more tabBar item comes by default.Now when i tap the more tabBar item the remaining items come in a tableview which is actually the view of a navigation controller(which comes by default).Now when i select any of the row, my new view controller gets pushed into that navigation controller.I want my view controller to be the navigation controller.So there is a situation like pushing a navigation controller onto the sack of another navigation controller.The compiler gets confused and it does nothing.
2.Although I have set autoresizing of each controller of tab bar controller nothing happens on rotating the device.However when I keep only five or less tabBar items,autoresizing works perfectly.
3.I want an ImagView at the top throughout the application, so I attached an imageview on the window itself and than increases the y-coordinate of the tabBar controller's view so that the navigation bar of each tabBar controller's view starts just below the imageview.Everything is fine for the portrait mode but as soon as i rotate the device the imageview dissappears.And when i again come to portrait mode the imageview does not appear and the tabBar controller's view starts from the top.
I tried it every ways(like tabBar instead of tabBar controller etc.) but fail to achieve anything helpful.
I've never heard of that problem before. Can you paste some code? Also, are you sure that the tabs on the view more page work correctly?
In order for a TBC to rotate, all of the root view controllers of each tab must support rotation. In each of those files make sure shouldRotateToInterfaceOrientation: returns YES for all orientations (if you're using the default iPhone VC template take out the if(interfaceOrientation == UIInterfaceOrientationPortrait) statement and associated brackets).
I've actually done this before, and trust me when I say you're opening up a can of worms. To achieve this you need to add the TBC as a subview of a view that has an imageview on top. You must manually set the TBC.view frame to not cover up the top image. The best way to do this is: in the .xib for the container file, add an image view up top, and under it another view. Connect the view to the code via an IBOutlet, and set that frame as the TBC.view.frame. Then add the TBC.view as a subview programmatically.
With this solution, however, you must add in a willRotateToInterfaceOrientation:duration: method that calls the same function in all the TBC's viewcontrollers, and all of those viewcontrollers must be navigation delegates that call viewWillAppear: and viewDisappear: manually. The rotation is also a bit "sticky" when you do this, so beware.
My suggestion: don't put a static image up top. It causes a lot of issues, and takes up a lot of screen real estate, especially on the iPhone's smaller screen. Look at The Weather Channel app if you want to see how bad it looks.
Let me know if you have any more questions!
I have a view (and corresponding view controller) in my iPhone app that allows the user to edit settings for the application. This view is accessible via a menu (a table view). I use pushViewController in my UIViewController subclass to get it shown. When I do this, it appears as I expect - the nav bar appears on top of the xib, and the empty space I left up there in the xib is occupied.
I also sometimes show that settings view as a modal view using presentModalViewController. When I do this, the top of the xib starts at the bottom of the nav bar instead of underneath it.
The documentation does say that presentModalViewController will resize the view to fit, so I could see this being expected behavior. However, for me, it isn't desired behavior.
I can kind of work around it by setting the settings view controller to not show the nav bar, but then there's a weird empty space at the top of the view.
Ideally, I'd like to use the same xib in both of these situations. However, maybe that's not a best practice? How do you guys usually reuse a xib?
I was thinking that maybe I could have the view controller shift all of the controllers up if it's in modal mode, but I'd like something better, if it's available.
Each UIView has an autoresizingMask property. By configuring that (can be done in Interface Builder), you should be able to reuse the view and have it automatically resize to take up the whole screen when the nav bar should not be there.
Apple's documentation is here:
http://developer.apple.com/iPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/WindowsandViews/WindowsandViews.html#//apple_ref/doc/uid/TP40007072-CH8-SW10
I have an app that uses a UINavigationController as its main way of showing data.I want a Settings screen to pop up, but I also want to be able to push new views for Settings. From what I've found, I can't use a UIViewController do to this. How can I present a view by sliding it, and also have content pushed onto it?
You can display the view for your view controller subclass either by presenting it modally (slides from the bottom and takes over the whole screen) or pushing it onto the navigation stack with animation (slides from the right and keeps the navigation bar).
In either case, you control the content of the view using your view controller subclass. Typically you update labels and controls in the viewWillAppear method.