How to detect tap on Uitableview cell with uiview and uibutton?

后端 未结 3 2040
南方客
南方客 2021-01-25 22:12

I have created a table view and i am adding my custom uiview into the cell\'s content view. The uiview has a uibutton. However i can add the uibutton into the content view when

3条回答
  •  余生分开走
    2021-01-25 22:26

    You can add a Button in cell in as

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    
    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake( 13.0f, 13.0f, 90.0f, 90.0f)];
    [button addTarget:self action:@selector(BtnPressed) forControlEvents:UIControlEventTouchUpInside];
    [cellView.contentView addSubview:button];
    

    then you can get events separately

提交回复
热议问题