UITableView のヘッダービューに UISegmentedControl があります。何らかの理由で、セグメントを選択できません。いつでも、配列の最後のセグメントが自動的に選択され、それ以外は選択できません。アクションを削除すると、どちらかを選択できます。何が起こっているのかわかりません。
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
if (section == 1) {
UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0,0, 320, 40)]; // x,y,width,height
NSArray *itemArray = [NSArray arrayWithObjects:@"E01", @"E02", @"E03", @"E05", @"E06", @"T05", @"E17", @"E19", nil];
control = [[UISegmentedControl alloc] initWithItems:itemArray];
[control setFrame:CGRectMake(30.0, 0, (tableView.bounds.size.width) - 60, 40)];
[control setSelected:YES];
[control setSegmentedControlStyle:UISegmentedControlStylePlain];
[control addTarget:self action:@selector(unitSegmentControl:) forControlEvents:UIControlEventValueChanged];
[headerView addSubview:control];
return headerView;
}
return nil;
}