![](/img/trans.png)
[英]Setters in UITextField in iOS7 doesn't work but work in iOS6
[英]UIButton addTarget doesn't work with iOS7,but works in IOS6
顯然,此代碼在iOS 6中有效。順便說一下,它在iOS 7中有問題。
我將UIButton添加到UIPickerView中的每一行:
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UIButton *btnRow=[UIButton buttonWithType:UIButtonTypeSystem];
[btnRow addTarget:self action:@selector(touch:) forControlEvents:UIControlEventTouchUpInside];
btnRow.frame=CGRectMake(0, 0, 320, 30);
int tag= selfTextField.tag/10000 - 1;
[btnRow setTitle:[[pickerArray objectAtIndex:tag] objectAtIndex:row] forState:UIControlStateNormal];
return btnRow;
}
您不能在選擇器視圖行上放置按鈕。 所以我在UIPickerView上方添加了一個工具欄,並在其上添加了一個條形按鈕項。 我使用行號通過選擇器執行所需的功能
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
....
//get the row number & Perform desired functionality
....
}
您將獲得行號,並使用該行號執行所需的功能。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.