I have a view consisting of a label and two buttons, which I named UIView *footerView
, as I am implementing this in the last section of my table view. I have this view become the view for indexPath.section = 3
by using [cell.contentView addSubview: footerView]
This is my Problem:
I can see the view inside the cell. But I cannot tap the buttons, as the cell gets selected instead of the buttons (which are inside the cells).
How do I get over this problem? My buttons are not even selectable!
Here's the code... In cellForRowAtIndexPath:
if (section == 3){
cell = nil;
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if (indexPath.row ==0){
cell.contentMode = UIViewContentModeScaleToFill;
[cell.contentView addSubview:self.footerView];
}
}
And the Footer view (in case anyone needs to see this):
UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 3, 300, 44)];
textView.text = @"Terms and Conditions: Lorem ipsum dolor sit amet, con- sectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut";
textView.backgroundColor = [UIColor clearColor];
textView.font = [UIFont systemFontOfSize:10];
[self.footerView addSubview:textView];
//create the button
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:CGRectMake(0, 60, 300, 44)];
//set title, font size and font color
[button setTitle:@"Create Account" forState:UIControlStateNormal];
[button.titleLabel setFont:[UIFont boldSystemFontOfSize:18]];
// [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//set action of the button
[button addTarget:self action:@selector(createAccount:)
forControlEvents:UIControlEventTouchUpInside];
[button setEnabled:YES];
//add the button to the view
[self.footerView addSubview:button];
UIButton *cancelButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[cancelButton setFrame:CGRectMake(0, 107, 300, 44)];
//set title, font size and font color
[cancelButton setTitle:@"Cancel" forState:UIControlStateNormal];
[cancelButton.titleLabel setFont:[UIFont boldSystemFontOfSize:18]];
// [button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
//set action of the button
[cancelButton addTarget:self action:@selector(cancelPressed:)
forControlEvents:UIControlEventTouchUpInside];
[cancelButton setEnabled:YES];
//add the button to the view
[self.footerView addSubview:cancelButton];