Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You will have to manage one more cell than your array element count. So make sure to make the following modifications in the table view datasource implementation :</p> <pre><code>// return the correct row count -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [theArray count] + 1; } // detect the last cell and add it a subview -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ... ... // detect the last row if(indexPath.row == [theArray count]) { UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom]; // set the frame and title you want [b setFrame:CGRectMake(0, 0, 50, 50)]; [b setTitle:@"button" forState:UIControlStateNormal]; // set action/target you want [b addTarget:self action:@selector(theActionYouWant:) forControlEvents:UIControlEventTouchDragInside]; [cell addSubview:b]; } else { // configure a classic cell } return cell; } // the action method -(void)theActionYouWant:(id)sender { // handle the action } </code></pre> <p>As an alternative, why not just use the whole cell to execute an action ? Use the same mechanism to manage one more cell, set it a custom label, and when you detect the cell is selected, send a message :</p> <pre><code>-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { if([indexPath row] == [theArray count]) { // the extra cell is selected, send a message } else { // others cells selection handler } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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