I have a problem with my click event here is the code:
-(void) viewWillAppear : (BOOL) animated {
footerView = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,300)];
UILabel *totallabel = [[UILabel alloc]initWithFrame:CGRectMake(50,5,320,40)];
totallabel.text = @"Grand Total =";
totallabel.font = [UIFont fontWithName:@"Lato-Regular" size:10];
totallabel.font = [UIFont systemFontOfSize:14];
[footerView addSubview:totallabel];
UILabel *lblRs = [[UILabel alloc]initWithFrame:CGRectMake(160,5,320,40)];
lblRs.text = @"Rs.";
lblRs.font = [UIFont fontWithName:@"Lato-Regular" size:10];
lblRs.font = [UIFont systemFontOfSize:14];
[footerView addSubview:lblRs];
totalcostlabel = [[UILabel alloc]initWithFrame:CGRectMake(190,5,320,40)];
totalcostlabel.font = [UIFont fontWithName:@"Lato-Regular" size:10];
totalcostlabel.font = [UIFont systemFontOfSize:14];
[footerView addSubview:totalcostlabel];
UIButton *aButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
aButton.frame = CGRectMake(70,50,150,40);
aButton.backgroundColor = [UIColor colorWithRed:119.0/225.0 green:49.0/
255.0 blue:88.0/255.0 alpha:1.0];
[aButton setTitle:@"Checkout" forState:UIControlStateNormal];
[aButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
aButton.titleLabel.font = [UIFont fontWithName:@"Lato-Regular" size:10];
[aButton addTarget:self action:@selector(btnChackOut:) forControlEvents:
UIControlEventTouchUpInside];
[footerView addSubview:aButton ];
[self.tblView setTableFooterView:footerView];
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:
(NSInteger)section {
return footerView;
}
- (void)btnChackOut:(UIButton *)sender {
NSLog(@"btn clicked");
}
When I click the Checkout button which is declared in my footer the click event is not performed and the action method is not getting called.
Tarun Kumar
25-Jul-2015Can't called because you don't set a height for footer, just need set footer height like this: