今天我有一個問題,從這個發芽:Database Results in Cocoa。這涉及使用數據庫返回的數據來創建一定數量的問題。我正在使用以下代碼的一種形式(這是張貼在問題中)。動態結果和覆蓋數據
NSMutableDictionary * interfaceElements = [[NSMutableDictionary alloc] init];
for (NSInteger i = 0; i < numberOfTextFields; ++i) {
//this is just to make a frame that's indented 10px
//and has 10px between it and the previous NSTextField (or window edge)
NSRect frame = NSMakeRect(10, (i*22 + (i+1)*10), 100, 22);
NSTextField * newField = [[NSTextField alloc] initWithFrame:frame];
//configure newField appropriately
[[myWindow contentView] addSubview:newField];
[interfaceElements setObject:newField forKey:@"someUniqueIdentifier"];
[newField release];
}
但是,現在當我嘗試使用IFVerticallyExpandingTextfield(從http://www.cocoadev.com/index.pl?IFVerticallyExpandingTextField),或產生任何大量的文字,它只是越過其他繪製的內容。我看着使用setAutosizingMask:在對象上,但它迄今還沒有工作。
感謝您的任何幫助。
編輯:我想要的效果是什麼樣子被稱爲「正確的文本字段」,併發生了什麼叫「StackOverflow的樣本」 - http://www.mediafire.com/?sharekey=bd476ea483deded875a4fc82078ae6c8e04e75f6e8ebb871。
編輯2:如果沒有人知道如何使用此IFVerticallyExpandingTextfield類,是否有人知道是否有其他方式來完成效果?
我不確定,但我認爲您應該使用NSScrollView而不是您的容器視圖的NSWindow的contentView。 – 2009-08-17 11:48:11
嗨Virgil:在我的實際代碼中,我使用的是NSScrollView,但使用它時仍然會出現問題。 – PF1 2009-08-17 16:00:25