我有兩個問題,我的tableview,即從tablefooterview的「回家」按鈕被顯示出來(在屏幕的中間)時,尚未達到桌面視圖的結尾。正如您在第一張圖片中看到的,主屏幕按鈕出現在屏幕中間,我不想要的。它必須留在桌子的底部。
我的第二個問題是分段控制,它通常位於視圖的頂部,正在我的一個單元中重新分配,它不屬於它。我已確定細胞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;
}
分機ra評論:我在不同的視圖中使用相同的頁腳(不同的tableview)只有一個部分,這裏按鈕顯示正確。
你可以發佈添加按鈕到腳註視圖和'cellForRowAtIndexPath'內的代碼的代碼嗎? –
我添加了代碼,你可以給它看看嗎? – Fuzej