[英]iPhone UITextField inputView error: Assignement to readonly property
I am having issues when I want to assign UIPicker as inputView of UITextField. 我想将UIPicker分配为UITextField的inputView时遇到问题。 It shows error " Assignement to readonly property ".
它显示错误“ 分配给只读属性 ”。 Please help as I think it is not related to property sythesizing.
请帮忙,因为我认为这与属性合成无关。
I have added my code below: 我在下面添加了我的代码:
@interface DriverWaitingDetails : UIViewController<UITextFieldDelegate,UIPickerViewDataSource, UIPickerViewDelegate>
{
IBOutlet UILabel *baseLabel;
IBOutlet UITableView *driverTableView;
IBOutlet UIPickerView *basePicker;
}
@property(nonatomic, retain) IBOutlet UIPickerView *basePicker;
@property(nonatomic,retain)IBOutlet UILabel *baseLabel;
@property(nonatomic,retain)IBOutlet UITableView *driverTableView;
@end
Implementation Code:- 实施代码:
-(void)viewDidLoad
{
basePicker=[[UIPickerView alloc] initWithFrame:CGRectMake(0,100,320, 500)];
self.navigationItem.title=@"Driver Table";
baseLabel.userInteractionEnabled = YES;
basePicker.delegate = self;
basePicker.dataSource = self;
[basePicker setShowsSelectionIndicator:YES];
baseLabel.inputView=nil;
[super viewDidLoad];
}
Attached Screenshot:- 附件截图:-
You are setting the input view of UILabel
. 您正在设置
UILabel
的输入视图。 You declared baseLabel as UILabel
not UITextField
. 您将baseLabel声明为
UILabel
而不是UITextField
。
IBOutlet UILabel *baseLabel;
You have declared 您已经声明
IBOutlet UILabel *baseLabel;
UILabel inherits from UIView : UIResponder : NSObject
and the property is defined in UIResponder
: UILabel继承自
UIView : UIResponder : NSObject
并且该属性在UIResponder
定义:
@property (readonly, retain) UIView *inputView
As the property inputView
is read only, you cannot assign any value to it. 由于属性
inputView
是只读的,因此您不能为其分配任何值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.