Why is uitableview underneath my uinavigationbar - iphone

I have a UINavigationController with a UIViewController (vc1) as the "root view controller". There are 3 views in the UIViewController:
HeaderView(UIViewSubclass)
UITableView (custom frame)
FooterView(UIViewSubclass)
The reason that the header/footer view are separate from the uitableview is because they need to be stationary and only allow the uitableview to scroll. When the vc1 is loaded everything is PERFECTLY in place and behaves as expected. However, when click on of the cell rows, navigate to vc2 and then navigate back to the vc1 my tableview is now "under" the uinavigationbar.
Note:
The root view controller (vc1) is a subclass of uiviewcontroller so that I could change the frame size for the tableview. The frame for the tableview is set in IB as (0,0, 320,300). As I stated before when the vc1 is originally loaded the tableview is aligned perfectly under the headerview, it is just when I navigate back to vc1 from vc2.
I have tried setting autoresizingMask to UIViewAutoresizingFlexibleTopMargin in viewDidLoad, but to noavail. All suggestions are greatly appreciated

I fixed my problem. The problem was related to an issue with Three20 ThumbnailViewController

Related

Retaining View between one view controller and UAModalPanel

I have two view controllers named as firstvc, secondvc. I have a subview in the firstvc, it looks like a form which has textfields. In firstvc there is a button to maximize that subview.
When I click on that, I am adding that subview to secondvc and I am presenting secondvc view in UAModalPanel. If I close that secondvc, firstvc should appear. My problem is that I was unable to retain that subview. It means when I close secondvc, firstvc subview is disappearing.
Can you suggest how to retain that subview between two view controllers?
-(IBAction)maximize:(id)sender
{
UIViewController *newview = [self.storyboard instantiateViewControllerWithIdentifier:#"second"];
[newview.view addSubview:subview];
UAModalPanel *modalpanelobject = [[UAModalPanel alloc]initWithFrame:self.view.bounds];
[modalpanelobject.contentView addSubview:newview.view];
[self.view addSubview:modalpanelobject];
[modalpanelobject showFromPoint:self.view.center];
}
I am the developer behind UAModalPanel. The panel does nothing to mess with the view hierarchy of views that are not added to the contentView so this problem probably would exist even without it. I would subclass the first controller's view and place a breakpoint in the dealloc and removeFromSuperview methods to see what is removing the view, when and why.
Look,
The concept is
There are three view you can consider.
Child View (ScrollView in your case)
Parent View 1 (GridCell)
Parent View 2 ('Maximized View)
What you are doing is when
1.You are maximizing the Child view
At that time you are taking the Child View from Grid Cell to Maximized View.
2.Now in reverse when you are closing the Maxized View.
Correct:At that time you SHOULD take the Child View from Maximized View to Grid Cell.
for doing that you can not find your Child View in Grid Cells.
Best Regards.

UINavigationBar not showing up in modal view

I have a storyboard as seen in this picture:
From a table view cell, I modally present a new view controller which is a subclass of UITableViewController. In the scene on the RHS I have a UINavigationBar. But when my view is presented, it does not have it. Why is that? Thanks!
You'll need to embed your subclass of UITableViewController that you want presented modally inside of a UINavigationController.
To do this, click the view you want presented modally in your Storyboard, then go to Editor>Embed In>Navigation Controller.

a view containing UITableView and UITabBar

I am using UINavigationController to push and pop other UIViewControllers in my app.
In one of the UIViewControllers I am using UITabBar to switch between different views. One of the view has UITableView and I am having difficulty showing the tabBar at the bottom. Even if it shows up it scrolls up and down with the tableCells.
I didn't use the tabbarcontroller because apple documentation recommends not to push tabbarcontroller on to navigationcontroller stack.
Thank you.
I guess that you are using UITableViewController. The View of the UITableViewController is the tableView itself, so when you add the tab bar to the view you actually add it to the table view. that is why it scrolls with it.
you should create a regular UIView, and then add the tableView and the tab bar to that view.
shani

Adding UIView subview to single table view controller in navigation stack

I'm working on an app that has three table view controllers in a navigation stack. The root view controller and the second VC have toolbars, but I want to add a subview to the second view controller like this. (The color is just there for visualization.)
I want to add the view programmatically, since I haven't been able to do it with IB without major headaches. Right now, I've been able to kind of get what I want by drawing a UIView in the second view controller like this:
- (void)viewDidLoad {
[super viewDidLoad]
UIView *detailView = [[UIView alloc] initWithFrame:CGRectMake(0, 392, 320, 44)];
detailView = [UIColor redColor];
[self.navigationController.view addSubview:detailView];
[detailView release];
}
The problem with this approach is that once the UIView is loaded in the second view controller, it stays loaded and is drawn in the third and root view controllers. I've tried a variety of methods of removing the UIView, including setting the detailView to nil in viewDidUnload, calling removeFromSuperview in didSelectRowAtIndexPath (which removed the view from the whole stack).
I've also tried adding the subview to self.view, but that pushes it below the visible area of the table view, so I have to scroll up to see it, and it snaps back down when I let go.
Clearly, adding this subview to the navigation controller is not the best way to do what I want, but I'm at a loss as to where to go from here.
As you've already discovered, you definitely should not be reaching up into the navigation controller's view.
You want your SecondViewController to be an UIViewController that implements the UITableViewDelegate and UITableViewDataSource and whose view lays out the UITableView and the UIView you wish to use for your stationary 'footer' in it's own main UIView.
It helps to keep in mind that UITableViewController is ultimately is just a convenience for creating a view controller whose view consists entirely of a UITableView.
Anyway, rather than attempt to put a pile of that code inline in this answer, you can browse it (or svn co) from this read-only svn repo.
EDITED (now that it's not midnight, putting some code/explanation directly in answer):
For the controller to be pushed onto the nav stack that needs the footer create a new UIViewController-based class (do NOT check the 'UITableViewController subclass' box in the template selection dialog).
Add instance variables for the UITableView and the UIView that is to be the extra bottom view.
#interface SecondViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> {
UITableView* tableView;
UIView* customFooterView;
}
#property (nonatomic,retain) IBOutlet UITableView* tableView;
#property (nonatomic,retain) IBOutlet UIView* customFooterView;
#end
In IB add a UITableView and UIView to the existing root view for the controller and lay them out as desired (probably worth altering the auto-resize parameters too if your app can be used in both landscape and portrait). Hook up the two views to the outlets defined for them in the "File's Owner" and also ensure you hook up the UITableView's delegate and dataSource properties to point at the "File's Owner."
Then just implement the UITableViewDelegate and UITableViewDataSource protocols as appropriate for your application.
If you want to lay out the entire 'footer' view in IB then go right ahead. Otherwise you can easily add items programmatically in viewDidLoad (and remember to tear it down in viewDidUnload).
I don't like the approach. You should put your table view inside another view, and put your detail view together in that view.
Despite of that, I think you can remove your view in viewWillDisappear method of your view controller. I also notice that you did not keep your detailView as a private variable, which you should do because you need to reference it when removing it later (I still wonder how you have done it.)
Note that viewDidUnload is called in case of view unloading (i.e. releasing from its controller), so it is not related to navigation.
Not sure which behavior you're looking for but try one of these:
Assign the detailView to the tableFooterView property of the tableview on the second VC.
Reduce the height of the table view and add the detailView to self.view.

Resizing viewControllers view that are part of a UINavigationController on IPhone

I am using a UINavigationController to handle the pushing and poping of viewControllers in my app. Theres a section where i have a tab bar (not using UITabbarController) which is manageed by the same UINavigationController, i simply add the UITabBar to the navigation controllers view (by using addSubview).
The Problem:
I have some UIViewControllers with table views being pushed into the navigation stack, since my Tab Bar is part of the view and not the navigation stack the TableViews are cut off at the buttom because the Navigation Controller does not know of the tab bar because its in its view and n ot the navigation stack. Without a navigation controller i would just resize the ViewControllers view and it would work fine, but when i try to do that it seems like the NavigationCOntroller just ignores my frame and sets its own and therefore the table views are cut off. I found one solution which was to add some extra cells and hide them and that works sort of OK but its kind of hackerish, anyone have any suggestion of how to go about this in a different non -hackerish way?
Thanks
Alright, so i solved the problem. I had tried resizing the UITableView instead of the viewController before, but this did not work. I just realized though, that this did not work because i was using a UITableViewController which manages its own tableView and was not letting me change the frame of it (maybe i was changing it in the wrong place, tried in viewDidLoad, i bet if i did it after the call to [super viewDidload] it would have worked..o well). So I changed the class to a UIViewController and managed the table view in there, now it works good, thanks for the replies.
Try making the root view a UIView with a UITableView for a subview. Then add the UITabBar to the UIView instance. Now the UITableView won't know about the UINavigationController.