【发布时间】:2012-11-20 11:02:52
【问题描述】:
我在选择器的委托方法中添加一个按钮作为行方法的视图。但是在 iOS4.0 中按钮没有被按下,它在 iOS5.0 及更高版本上工作正常。
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
NSArray *__autoreleasing views = [[NSBundle mainBundle] loadNibNamed:@"PickerRowView" owner:self options:nil];
self.pickerDataView = [views lastObject];
self.labelBtn = (UIButton *) [pickerDataView viewWithTag:101];
[self.labelBtn addTarget:self action:@selector(labelBtnPressed:)forControlEvents:UIControlEventTouchUpInside];
return pickerDataView;
}
此代码在 iOS5 及更高版本上运行良好,但在 iOS4.0 上运行良好。谁能告诉它为什么会发生??
【问题讨论】:
-
pickerData 视图,我添加为行视图包含一个按钮,该按钮没有被按下,因此它的动作选择器在 iOS4.0 中没有被触发
-
你确定在 iOS4 中,
self.labelBtn不是 nil 吗? -
@iVishal 检查 self.labelBtn = (UIButton *) [pickerDataView viewWithTag:101];然后 self.labelBtn 这有任何参考 some thing.means 有参考...
-
是的,当然,相同的代码在 iOS5 及更高版本上运行良好。在 iOS4.0 中,当我按下按钮时,它的文本会突出显示,但它的动作不会被调用。
-
@iOS-Deveoper 是的,它有参考,我刚刚检查过...0x6a92730
标签: objective-c ios uibutton uipickerview