iPhone UITextField inputView错误:对readonly属性的Assignement

时间:2012-11-08 08:28:24

标签: iphone ios uitextfield uipickerview

当我想将UIPicker分配为UITextField的inputView时,我遇到了问题。它显示错误“ Assocnement to readonly property ”。请帮忙,因为我认为它与财产合成无关。

我在下面添加了我的代码:

@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

实施守则: -

-(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];    
}

附加屏幕截图: - UITextField Error Image

2 个答案:

答案 0 :(得分:5)

您正在设置UILabel的输入视图。 您将baseLabel声明为UILabel而不是UITextField

IBOutlet UILabel *baseLabel;

答案 1 :(得分:0)

您已宣布

IBOutlet UILabel *baseLabel;

UILabel继承自UIView : UIResponder : NSObject,该属性在UIResponder中定义:

@property (readonly, retain) UIView *inputView

由于属性inputView是只读的,因此您无法为其指定任何值。