Reputation: 920
I am having issues when I want to assign UIPicker as inputView of UITextField. 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:-
Upvotes: 1
Views: 1956
Reputation: 126
You have declared
IBOutlet UILabel *baseLabel;
UILabel inherits from UIView : UIResponder : NSObject
and the property is defined in UIResponder
:
@property (readonly, retain) UIView *inputView
As the property inputView
is read only, you cannot assign any value to it.
Upvotes: 0
Reputation: 107131
You are setting the input view of UILabel
.
You declared baseLabel as UILabel
not UITextField
.
IBOutlet UILabel *baseLabel;
Upvotes: 5