【发布时间】:2015-11-11 19:53:39
【问题描述】:
我有一个带有一行的 UITableView,在这一行内我有一个带有 3 个段的 UISwitch。就我而言,我需要使用按标签选择的代码来获取选定的索引:
- (void)viewDidLoad {
[super viewDidLoad];
UITableViewCell *cellAttachment = [_tableView dequeueReusableCellWithIdentifier:@"MyCell0"];
UISegmentedControl *btnAttachment = nil;
btnAttachment = (UISegmentedControl*)[cellAttachment viewWithTag:100];
NSLog(@"Segment -> %ld",(long)btnAttachment.selectedSegmentIndex);
}
使用此代码,我可以选择段,但是当我尝试更改段时:
btnAttachment.selectedSegmentIndex = [self.arrayFields[19] intValue];//Inside this array has a number 1!
什么都没做,有什么问题吗? (我没有 IBOutlet,可能吗?)
【问题讨论】:
标签: ios objective-c uitableview uiswitch