Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>you can do something like this </p> <pre><code>- (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]; UIButton * btnShare=[[UIButton alloc] initWithFrame:CGRectMake(270,0,32,32)]; [btnShare setImage:[UIImage imageNamed:@"check-box.png"] forState:UIControlStateNormal]; [btnShare setImage:[UIImage imageNamed:@"check-box-selected.png"] forState:UIControlStateSelected]; [btnShare addTarget:self action:@selector(accessoryButtonTapped:withEvent:) forControlEvents: UIControlEventTouchUpInside]; cell.accessoryView = btnShare; [btnShare release]; } BOOL isShared = ([arrayOfSelectedIndex indexOfObject:[NSNumber numberWithInt:indexPath.row]] != NSNotFound); UIButton* btnShare1 = (UIButton*)cell.accessoryView; btnShare1.selected = isShared; [btnShare1 setNeedsDisplay]; return cell; } </code></pre> <p>where arrayOfSelectedIndex is an array containing all the indexes which are selected.</p> <p>There are few more methods aiding the multi selection of rows but I am sure the above snippet can give you some idea as to how to get check boxes in cells. <img src="https://i.stack.imgur.com/3PGTI.png" alt="enter image description here"> <img src="https://i.stack.imgur.com/RSuTH.png" alt="enter image description here"></p> <p>Hope it helps..Cheers</p> <pre><code>- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{ [tableView reloadData]; } - (void) accessoryButtonTapped: (UIControl *) button withEvent: (UIEvent *) event{ NSIndexPath * indexPath = [neighbourTableView indexPathForRowAtPoint: [[[event touchesForView: button] anyObject] locationInView: neighbourTableView]]; if ( indexPath == nil ) return; [arrayOfSelectedIndex removeAllObjects]; [arrayOfSelectedIndex addObject:[NSNumber numberWithInt:indexPath.row]]; [self tableView:neighbourTableView accessoryButtonTappedForRowWithIndexPath:indexPath]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [arrayOfSelectedIndex removeAllObjects]; [arrayOfSelectedIndex addObject:[NSNumber numberWithInt:indexPath.row]]; [tableView reloadData]; } </code></pre>
    singulars
    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. 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