views:

1045

answers:

4

Hi Guys,

I have some signup form that had email and login text fields as table cells and signup button as button in footer view. That all functioned superb, here is the code

frame = CGRectMake(boundsX+85, 100, 150, 60);
 UIButton *signInButton = [[UIButton alloc] initWithFrame:frame];
 [signInButton setImage:[UIImage imageNamed:@"button_signin.png"] forState:UIControlStateNormal];
 [signInButton addTarget:self action:@selector(LoginAction) forControlEvents:UIControlEventTouchUpInside];

 self.navigationItem.hidesBackButton = TRUE;
 self.tableView.tableFooterView.userInteractionEnabled = YES;
 self.tableView.tableFooterView = signInButton;
 self.view.backgroundColor = [UIColor blackColor];

My question is how to add another button next to this one.

By using [self.tableView.tableFooterView addSubview:...] buttons are not shown and if I use some other UIView, place buttons there and then say that the footerView is that UIView, I see the buttons, but am unable to press them.

I hope that this isn't too confusing and that you understand my problem.

Thx in advance, Mladjo

A: 

Humm, I didn't read this close enough before answering. I think you need to set the container UIView's userInteractionEnabled property then as you tried, set the footerView to the container with the subviews.

wkw
+1  A: 

your first try is wrong, if you are doing as you as saying you are trying to add a button to the subview of a button:

first you

... 
self.tableView.tableFooterView = signInButton;
...

and then later

... 
[self.tableView.tableFooterView addSubview:...]
...

but tableFooterView is signInButton. So that is why that is not working.

your second try is correct and the answer yonanderson pointed you should work out and is the correct way to do this, you just need to :

[yourButtonsView addSubView:button1];
[yourButtonsView addSubView:button2];
yourButtonsView.userInteractionEnabled = YES;
self.tableView.tableFooterView = yourButtonsView;
self.tableView.tableFooterView.userInteractionEnabled = YES;
deoryp
Here is my code:UIView *footerView = [[UIView alloc ] init]; [footerView addSubview:signInButton]; [footerView addSubview:signUpFreeButton]; footerView.userInteractionEnabled = YES; self.navigationItem.hidesBackButton = TRUE; //[self.tableView.tableFooterView addSubview: signInButton]; self.tableView.tableFooterView = footerView; self.tableView.tableFooterView.userInteractionEnabled = YES;But the buttons are still unclickable :(
Mladen
A: 

It took me forever to figure out why my footer's buttons were not calling the designated actions. Finally I discovered that I needed to adjust my footer's height. This fixed it for me:

-(CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return footerView.bounds.size.height;
}
Gorgando