Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling IBAction Programmatically in TableViewHeader
    primarykey
    data
    text
    <p>I am creating a button pro-grammatically in my TableView Header cell and adding TouchUpInside Action to it. With UIButton Header contains two other UILabels also.</p> <p>Problem : If Button Is added as SubView, Its not respondin.</p> <p>But when I return only UIButton from Method It is working fine.</p> <p>Here is my code of <code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section</code></p> <pre><code>- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { UIView *viewHeader = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 60)]; viewHeader.tag = 101; viewHeader.backgroundColor = [UIColor cyanColor]; UIButton *btnBack = [UIButton buttonWithType:UIButtonTypeRoundedRect]; btnBack.frame = CGRectMake(15, 15, 50, 25); //btnBack.titleLabel.text = @"Back"; [btnBack setTitle:@"Back" forState:UIControlStateNormal]; [btnBack addTarget:self action:@selector(Back:) forControlEvents:UIControlEventTouchUpInside]; btnBack.userInteractionEnabled = YES; UILabel *lblPlayerName = [[UILabel alloc]initWithFrame:CGRectMake(75, 20, 60, 20)]; lblPlayerName.backgroundColor = [UIColor redColor]; UILabel *lblHighScoreOfPlayer = [[UILabel alloc]initWithFrame:CGRectMake(215, 20, 80, 20)]; lblHighScoreOfPlayer.backgroundColor = [UIColor yellowColor]; } lblPlayerName.text = [@"Name" uppercaseString]; lblHighScoreOfPlayer.text = [@"Scores" uppercaseString]; [viewHeader addSubview:btnBack]; [viewHeader addSubview:lblPlayerName]; [viewHeader addSubview:lblHighScoreOfPlayer]; return viewHeader; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload