我有一個UIToolbar
並添加了幾個UISegmentedControl
它。我的問題是我selector
爲UISegmentedControl
是沒有得到所謂的IOS 11.但是在IOS 10和較低版本的正常工作。UISegmentedControl的選擇器沒有爲ios 11中的事件UIControlEventValueChanged觸發
我有一個UITextField
針對我有一個日期選擇器作爲一個輸入視圖和我已經加入此工具欄作爲assesory圖。當我點擊工具欄中的完成按鈕時,我設置了UITextField
的值。
UIToolbar *toolBar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 50)];
[toolBar setBackgroundColor:[UIColor whiteColor]];
doneButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:"done" ]];
doneButton.momentary = YES;
doneButton.frame =CGRectMake(toolBar.frame.size.width - 50,5 , 30, toolBar.frame.size.height- 2 *5);
[doneButton setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin];
doneButton.tintColor = [UIColor blackColor];
[doneButton addTarget:self action:@selector(donePressed) forControlEvents:UIControlEventValueChanged];
[toolBar addSubview:doneButton];
的donePressed
方法不會被調用在IOS 11.0,但相同的代碼工作在較低的IOS版本的罰款。
請指教任何修復。
把donePressed()方法的代碼 – iPatel
很簡單 - (void)donePressed {}。 –