つまり、テーブルビューの最後にまだ到達していないときに、テーブルフッタービューの「ホームに戻る」ボタンが (画面の中央に) 表示されます。最初の写真でわかるように、ホーム ボタンが画面の中央に表示されていますが、これは望ましくありません。テーブルの一番下にとどまらなければなりません。
私の 2 番目の問題は、通常はビューの上部に配置されているセグメント化されたコントロールが、属していない 1 つのセルで再発生することです。cell reusidentifier が無効になっていることを確認しました。
セルにはテキストが入力されているだけなので、セグメント化されたコントロールが表示される理由がわかりません。
編集:コードが追加されました
セルを埋めるためのコード: (その一部ですが、別のセルの別のテキストであり、何も変わりません)
if(indexPath.section == 2){
[[cell textLabel] setTextAlignment:UITextAlignmentLeft];
[[cell textLabel] setText:_actor.actorBeschrijving];
if([[cell textLabel] text] == nil)
{
[[cell textLabel] setText:@"Druk om een beschrijving toe te voegen"];
[[cell textLabel] setTextColor:[UIColor grayColor]];
}
}
if(indexPath.section == 3 && control.selectedSegmentIndex == 1){
if([has count] == 0){
[[cell textLabel] setTextAlignment:UITextAlignmentLeft];
[[cell textLabel] setText: @"Voeg een nieuw object toe"];
}
else{
if(indexPath.row < [has count]){
AnObject *object = (AnObject*)[has objectAtIndex:indexPath.row];
[[cell textLabel] setTextAlignment:UITextAlignmentLeft];
[[cell textLabel] setText:object.objectNaam];
}
if(indexPath.row == [has count]){
[[cell textLabel] setTextAlignment:UITextAlignmentLeft];
[[cell textLabel] setText:@"Voeg een nieuw object toe"];
}
}
}
if(indexPath.section == 3 && control.selectedSegmentIndex == 3){
if([isResponsible count] == 0){
[[cell textLabel] setTextAlignment:UITextAlignmentLeft];
[[cell textLabel] setText: @"Voeg een nieuwe goal toe"];
}
else{
if(indexPath.row < [isResponsible count]) {
Goal *goal = (Goal*)[isResponsible objectAtIndex:indexPath.row];
[[cell textLabel] setText:goal.goalNaam];
}
if(indexPath.row == [isResponsible count]){
[[cell textLabel] setTextAlignment:UITextAlignmentLeft];
[[cell textLabel] setText: @"Voeg een nieuwe goal toe"];
}
}
}
フッターのコード:
@property (nonatomic, retain) IBOutlet UIView *myFooterView;
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
if(section == tableView.numberOfSections - 1)
return 50.0f;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
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;
}
追加コメント: セクションが 1 つしかない別のビュー (別のテーブルビュー) で同じフッターを使用していますが、ここではボタンが正しく表示されています。