I'm building an iPhone application and in one of my problems, I am trying to resize sub views. First, I have a Table View that when each data is tapped, it opens a new view. But the problem is that images and text in that opened view (which contains a Navigation Controller) is not aligned properly. They are all misplaced and my guesses is that on that view, it's only showing 3/4 of the top, not the whole view (which most of my images at the bottom are only showing half of the image). My goal is to fit every image and text to fit into my view that contains a Navigation Controller at the top of my view. So after researching, I can change the size and position in Interface Builder, but for some reason they are blank which I开发者_JAVA百科 can't edit:
In addition, I tried this code in my viewDidLoad:
// DetailViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
self.view.autoresizesSubviews = YES;
self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
So far none of these are even resizing my view to fit with my navigation controller, so I hope someone has a better idea how to resize and fit my view with Navigation Controller, thanks
Let me summarize, so I get what you're trying to do here. You have a view with a UITableView. When you select a cell in that table view, you push a new view onto the navigation stack. In that new view, parts of your layout are obscured at the top by the navigation controller's nav bar?
Assuming I'm right...
You're issue is with the autoresizing mask of the view (and subviews) of the view that is being pushed onto the navigation stack. You'll need to set it in Interface Builder to see the correct results. It should look like this:
This means that the view will shrink and grow to match any size constraints that it finds itself under. In the case of being shown in a UINavigationController, it will shrink itself so that it fits in the smaller screen space between the nav bar and optional toolbar.
Take care to also set appropriate autoresizing masks on all of the subviews of this view as well, such that they all handle arbitrary resizing appropriately.
精彩评论