2
我正在構建一個UITextField
,它使用UIPickerView
來允許用戶從狀態列表中進行選擇。爲了消除視圖,我嘗試添加一個UIToolbar
作爲此輸入的附件視圖,其中包含響應操作以關閉輸入視圖的UIBarButton
。下面是它的代碼:UIToolbar附件視圖UITextField無響應
- (void)viewDidLoad
{
[super viewDidLoad];
// Load state names.
NSString* file = [[NSBundle mainBundle] pathForResource:@"States" ofType:@"plist"];
self.states = [[NSArray alloc] initWithContentsOfFile:file];
// Initialize the picker view.
self.picker = [[UIPickerView alloc] init];
[self.picker setDelegate:self];
// Initialize the button view.
toolbar = [[UIToolbar alloc] init];
[toolbar setDelegate:self];
[toolbar setBarStyle:UIBarStyleDefault];
done = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(resignFocus:)];
[toolbar setItems:[NSArray arrayWithObjects:done, nil] animated:YES];
// Set the picker view as the state field input view.
// Also set the done button as it's accessory.
[[self state] setInputView:self.picker];
[[self state] setInputAccessoryView:self.toolbar];
}
隨着當我開始編輯特定的文本字段選擇器,工具欄都出現在這個代碼。問題是我無法與按鈕交互 - 沒有任何跡象表明水龍頭可以通過它。該按鈕不會像按鈕應該突出顯示,並且該操作永遠不會被觸發。是否有可能選擇器視圖以某種方式與工具欄重疊,從而阻止輸入達到它?
我正在開發這個iOS7,我用模擬器來測試它。
是的。最有可能的東西是重疊的按鈕。 –