我必須升級一個現有的應用程序和neeed以將其現有的UI分割爲單獨的NIB。我計劃開始爲所有拆分的UI創建單獨的NIB和NSViewController。現在問題是我的NSViewController沒有在鍵盤TAB和SHFIT + TAB事件上做出響應,我只是希望我的NSViewController在用戶單擊TAB或SHIFT + TAB時在我的動態加載的NSViewController視圖中將焦點設置爲適當的子控件。如何使視圖的子控件將關注NSViewController中的Tab和Shift + Tab
感謝,
編輯: 以下是我的要求。
我有三個子視圖,我需要動態加載並在我的MainWindow佔位符NSBox中使用NSPopupButton進行切換。
爲了檢查我創建了新的可可應用程序,並將一個NSPopupButton和NSBox添加到窗口並加入了NSPopupButton和NSBox的插座。
其次,我創建了三個新的NSViewController,其中包含三個不同的NIB,其中包含單獨的包含兩個或三個NSTextField子控件的自定義視圖。
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
}
在主應用程序代理功能我加入所有三個NSViewController的一個數組,後來交換使用replaceSubview替換佔位符NSBox的意見看法。
我已經在所有三個NSViewController中添加了以下代碼,但是我仍然沒有通過按TAB或SHIFT +製表鍵來關注子控件。
- (void)loadView {
[super loadView];
// store the responder that’s right after the view in the responder chain
NSResponder *nextResponder = [[self view] nextResponder];
// set the view controller (self) as the next responder after the view
[[self view] setNextResponder:self];
// set the stored responder as the next responder after the view controller
[self setNextResponder:nextResponder];
}
另外我還加入nextKetView在所有三個NIB的 – AmitSri 2011-02-16 08:15:08