Note that there are some explanatory texts on larger screens.

plurals
  1. POTwo buttons in UITableviewCell
    text
    copied!<p>I have a problem with button in UITableViewCell. Please help me.</p> <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator]; switch (indexPath.section) { case 0: break; case 2:{ cell.accessoryType = UITableViewCellAccessoryNone; // Make backgroung invisible [self cellBackground:cell]; // Make the save button [self saveButton:cell]; [self showButton:cell]; } break; } } return cell; } - (void)saveButton:(UITableViewCell *)cell { UIButton *saveButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [saveButton setTitle:@"Save" forState:UIControlStateNormal]; saveButton.frame = CGRectMake(45, 0, 300, 45); saveButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft; saveButton.contentEdgeInsets = UIEdgeInsetsMake(0,10,0,0); [cell addSubview:saveButton]; } - (void)showButton:(UITableViewCell *)cell{ UIButton *showButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [showButton setTitle:@"Show" forState:UIControlStateNormal]; showButton.frame = CGRectMake(45, 0, 300, 45); showButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentRight; showButton.contentEdgeInsets = UIEdgeInsetsMake(0,10,0,0); [cell addSubview:showButton]; } </code></pre> <p>I just want to have saveButton and showButton side by side in the indexPath.section = 2, and the size of button should fit the size of cell in landscape or portrait. Do you know how to do that? Thanks.</p>
 

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