CGRect未设置

时间:2014-02-15 01:32:20

标签: cgrect

这似乎是一个我想念的简单问题,但我显然无法看到它。我只是想在frame上调整一个值,所以我正在复制我的视图帧:

CGRect titleFrame = titleToolbar.frame;
CGRect addressFrame = addressToolbar.frame;
CGRect toolbarFrame = toolbar.frame;
CGRect webFrame = self.view.bounds;

NSLog(@"addressToolbar.frame.size.height = %f",addressToolbar.frame.size.height);
NSLog(@"addressFrame.size.height = %f",addressFrame.size.height);

但它正在退出:

2014-02-14 17:28:33:846 Lexly[5282:2571] - addressToolbar.frame.size.height = 44.000000
2014-02-14 17:28:33:847 Lexly[5282:2571] - addressFrame.size.height = 0.000000

addressFrame.size.height登录到44时,为什么addressToolbar.frame.size.height注销为0?


修改

addressToolbar设置在此处,在viewDidLoad的{​​{1}}中调用。你可以看到它是UIViewController。我在此方法中包含了对UIView的每个引用,但忽略了其他视图的初始化:

addressToolbar

- (void)setupView { ////////////////////// // Setup view CGRect viewFrame = self.view.bounds; CGFloat navBarHeight = self.navigationController.navigationBar.frame.size.height; CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height; addressToolbar = [[UIView alloc] initWithFrame:CGRectMake(0, navBarHeight + statusBarHeight, 320, 44)]; ... [addressToolbar addSubview:urlField]; [addressToolbar addSubview:loadingIndicator]; ... [self.view addSubview:addressToolbar]; } 的高度在创建后记录到addressToolbar

0 个答案:

没有答案