i added a button to my tableview programmatically but it is visible only if i select the tableview cell.how can i make it appear regardless of the selection of the tableview and i want to make the selection style of tableviewcell none.how to proceed. this is the code i used
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
ContactDetails *cont= [self.contactarray objectAtIndex:indexPath.row];
MyAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
for(ContactDetails *mycontact in delegate.contactsArray )
{
if([mycontact.contactID isEqualToString:cont.contactID])
{
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(100, 0, 100, 40);
[button setTitle:@"add contact" forState:UIControlStateNormal];
button.backgroundColor = [UIColor blueColor];
[button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button addTarget:self action:@selector(deconnect) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button];
[cell.contentView bringSubviewToFront:button];
}
}
cell.开发者_如何学PythontextLabel.text=cont.name;
return cell;
}
sorry the right way was to put [cell addSubview:button];
sorry for trble
精彩评论