You need to make sure that you first indicate the color or background of the table view that you want to give and remove the rows of the table view, and this will give the feeling that you are in sight and not on the table view
TableView.separatorStyle=UITableViewCellSeparatorStyleNone;
and after that clean the cell using
cell.backgroundColor = [UIColor clearColor];
and now the main thing is that you need to create a table this way
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { NSString *CellIdentifier = [NSString stringWithFormat:@"identifier_%d", indexPath.row]; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; //if (cell == nil) if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ; UIButton *contactUsBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect]; contactUsBtn.frame = CGRectMake(220, 10, 20, 20); contactUsBtn.tag = indexPath.row; [contactUsBtn setBackgroundImage:[UIImage imageNamed:@"TroubleImg.png"] forState:UIControlStateNormal]; [contactUsBtn addTarget:self action:@selector(contactUsBtnAction:) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:contactUsBtn]; } return cell; }
and the selector will like
-(void)contactUsBtnAction:(UIButton*)sender { UIButton *Button = (UIButton *)sender; NSLog(@"Selected button tag is %d", Button.tag); }
also check function
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSLog(@"index path %d",indexPath.row); [tableView deselectRowAtIndexPath:indexPath animated:YES]; }
I think this will help you a lot more.
source share