使うviewForFooterInSection
ときだから使う
tableView.tableFooterView = footerView;
私のボタンはタッチできません。そのため、最後のセクションがどこにあるかを手動で示したいと思います。
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
if(control.selectedSegmentIndex == 1 && section == 1)
{
if(myFooterView == nil) {
//allocate the view if it doesn't exist yet
myFooterView = [[UIView alloc] init];
//create the button
UIButton *footButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[footButton setFrame:CGRectMake(110, 10, 100, 30)];
//set title, font size and font color
[footButton setTitle:@"Go Home" forState:UIControlStateNormal];
[footButton.titleLabel setFont:[UIFont boldSystemFontOfSize:18]];
//set action of the button
[footButton addTarget:self action:@selector(clickPressed:)
forControlEvents:UIControlEventTouchUpInside];
//add the button to the view
[myFooterView addSubview:footButton];
}
//return the view for the footer
return myFooterView;
}
}
このコード行は私にEXC_BAD_ACCESS
エラーを与えています、そして私はセクションが存在すると確信しています:
if(control.selectedSegmentIndex == 1 && section == 1)
何が問題なのかわかりません。
編集:
@property (nonatomic, retain) UISegmentedControl *control;
- (void)viewWillAppear:(BOOL)animated
{
[self setTitle:_actor.actorNaam];
NSLog(@"Actor viewwillappear %@", _actor.actorNaam);
NSArray *items = [[NSArray alloc] initWithObjects: @"Actor", @"Object", @"Operation", @"Goal", nil];
control = [[UISegmentedControl alloc] initWithItems:items]; //!!!!!!!!!!!!!!!
control.selectedSegmentIndex = segmentPushed;
control.segmentedControlStyle = UISegmentedControlStylePlain;
control.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
control.apportionsSegmentWidthsByContent = YES;