Home > DeveloperSection > Forums > I have declared UIView and UIButton in the UIView
Felix Pickles
Felix Pickles

Total Post:24

Points:168
Posted on    July-24-2015 11:31 PM

 iPhone iPhone  Ios  Objective C 
Ratings:


 1 Reply(s)
 479  View(s)
Rate this:

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

Total Post:210

Points:1614
Posted on    July-25-2015 7:49 AM

Can't called because you don't set a height for footer, just need set footer height like this:

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:

(NSInteger)section {
    return 300;
}

 


Modified On Jul-25-2015 07:49:59 AM

Don't want to miss updates? Please click the below button!

Follow MindStick