I have two problems with my tableview, namely, the "Go Home" button from the tablefooterview is showing up (in the middle of the screen) when the end of the tableview isn't reached yet. As you can see in the first picture, the home button is occurring in the middle of the screen, what I don't want. It has to stay at the bottom of the table.
My second problem is the segmented control, which is normally positioned at the top of the view, is reoccuring in one my cells, where it doesn't belong. I've made sure cell reusidentifier is disabled.
Cells are just filled with text, so I don't see why the segmented control is showing up.
EDIT: Code added
Code for filling up Cells: (just a piece of it, but it's just other text in another cell, nothing changes)
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"];
}
}
}
Code for the footer:
@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;
}
Extra comment: I'm using the same footer in a different view (different tableview) with only one section, and here the button is showing correctly.