我的代码中出现了错误的访问错误,我不知道为什么。
这是我的代码
-(IBAction)datePickerValueChanged:(UIDatePicker *)sender{
myDatePicker = [[myDatePickerView subviews] lastObject];
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setLocale:sender.locale];
[dateFormatter setDateStyle:NSDateFormatterMediumStyle];
activeTextField = (UITextField *) [self.view viewWithTag: *(tag)];
[activeTextField setText:[dateFormatter stringFromDate:[sender date]]];
}
P.S:我在@interface中创建了activeTextField属性,就像这样
@property (nonatomic,strong) UITextField *activeTextField;
我合成了它
@synthesize activeTextField;
答案 0 :(得分:1)
尝试替换此行
activeTextField = (UITextField *) [self.view viewWithTag: *(tag)];
与
activeTextField = (UITextField *) [self.view viewWithTag: tag];//tag should be an integer