我有一个分段控件,当触摸已选择 selectedSegmentIndex 的日志时。但是它输出null
为 self.sessoField.text;
知道如何解决这个问题吗?
谢谢
这是来自以下内容的控制台输出:
2013-10-24 11:00:11.131 [3628:60b] gender is (null) 1
2013-10-24 11:00:40.179 [3628:60b] gender is (null) 0
2013-10-24 11:00:41.546 [3628:60b] gender is (null) 1
.
- (IBAction)genderSelectButton:(id)sender {
if (self.segmentedControlGender.selectedSegmentIndex == 0) {
self.sessoField.text = @"m";
NSLog(@"gender is %@ %d",self.sessoField.text,self.segmentedControlGender.selectedSegmentIndex);
} else if(self.segmentedControlGender.selectedSegmentIndex == 1) {
self.sessoField.text = @"f";
NSLog(@"gender is %@ %d",self.sessoField.text,self.segmentedControlGender.selectedSegmentIndex);
}
}
sessoField 已在 .h 中声明为:
@property (nonatomic, weak) IBOutlet UITextField * sessoField;