forum

Home / DeveloperSection / Forums / I have declared UIView and UIButton in the UIView

I have declared UIView and UIButton in the UIView

Anonymous User 1601 24-Jul-2015

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.


Updated on 25-Jul-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By