---
title: "I have declared UIView and UIButton in the UIView"  
description: "I have declared UIView and UIButton in the UIView"  
author: "Anonymous User"  
published: 2015-07-24  
updated: 2015-07-25  
canonical: https://www.mindstick.com/forum/23374/i-have-declared-uiview-and-uibutton-in-the-uiview  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 1 minute  

---

# I have declared UIView and UIButton in the UIView

I have a [problem](https://yourviews.mindstick.com/view/81399/tackling-the-problem-of-unemployment-during-corona-pandemic) with my [click event](https://www.mindstick.com/forum/424/how-to-call-form_paint-event-on-button-click-event) here is the [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):

```
-(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](https://www.mindstick.com/articles/63/how-to-add-button-in-datagridview-in-csharp-dot-net) which is declared in my footer the click event is not performed and the [action method](https://www.mindstick.com/forum/160300/how-to-pass-data-to-an-httppost-action-method-in-a-dot-net-core-api) is not getting called.

## Replies

### Reply by Tarun Kumar

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;}
```


---

Original Source: https://www.mindstick.com/forum/23374/i-have-declared-uiview-and-uibutton-in-the-uiview

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
