在我的應用程序中,我需要有一個splitView
,並且能夠將自己的視圖插入窗格。Xcode,自定義視圖 - 零框架/邊框
爲此,在界面構建器中,我創建了帶有兩個分隔符(三個窗格)的SplitView
,並將這三個窗格中的「自定義視圖」添加到IBOutlets
到我的對應視圖控制器。但是,當我查詢IBOutlets
的幀/邊界大小時,它們都是0.00000。
爲什麼我在Xcode中創建的自定義視圖有0大小?我該如何解決這個問題?
UPD:代碼查詢幀/窗格的界限:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.logList = [[LogListViewController alloc] initWithNibName:LOGLISTXIB bundle:nil];
[self logARect:self.leftPane.bounds withName:@"LeftPane bounds"];
[self logARect:self.leftPane.frame withName:@"LeftPane Frame"];
}
}
- (void) logARect:(NSRect) theFrame withName:(NSString *)name {
NSLog(@"%@ frame: %lf, %lf, %lf, %lf", name, theFrame.origin.x, theFrame.origin.y, theFrame.size.width, theFrame.size.height);
}
UPD2與此同時,當我通過self.view.subviews[0]
訪問窗格,我得到正確的大小。
你可以顯示你正在使用的代碼來查詢這些自定義視圖的大小和範圍嗎? –
@AdamRichardson我已經添加了相關的代碼作爲我的文章的更新。謝謝。 – Ibolit