开发者

SubView doesn't want to fit into specified frame

The the problem arises when i dynamically load subview from nib and add it to the current main view during viewDidLoad.

UIView *someView = // load from nib
someView.frame 
    = CGRectMake(.0, 
                .0, 
                kFormSheetWidth /* = 540.0 */, 
                kFormSheetHeight) /* = 576.0 */;
[self.view addSubview:someView];

It all happens inside FormSheet window, where UINavigationController instance was passed into presentModalViewController:. But, someView always resizes itself to be by 220.0 larger and by 116.0 higher and thus doesn't fit into window.

someView nib looks like

UITableView

xx UIView

xxxx UITextInput

xx UIButton

All these views have autoresizeSubviews == YES, clipSubviews == YES.

It's very surprising behavior. Interestingly, when I set the frame of someView in viewWillAppear:, ev开发者_运维百科erything looks fine. What (where) should I look for to tackle this thing?


Are you doing this is landscape mode? (ipad I assume because of the dimensions?)

This is a bit of a stab in the dark, but its a problem for a lot of people. (if its not it I appologize)

UINavigationController's rootview doesn't handle the

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

method like your code does, so you need to subclass UINavigationController and implement it like your view controllers so it doesn't always add the views in portrait.


Some view is resizing itself after you create its frame on the viewDidLoad.

What you should do, is set the autoresizeSubviews to NO or just set it's frame in the viewWillApear.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜