![](/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.