Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: None  |  size: 0.57 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Table view cell as button
  2. -(IBAction)buttonPressed{
  3. //Do my stuff
  4. }
  5.        
  6. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  7.  
  8.     //check if your cell is pressed
  9.     BOOL myCellIsPressed = ...
  10.  
  11.      if(myCellIsPressed)
  12.         [self buttonPressed];
  13. }
  14.        
  15. int myCellRow = 5;
  16. if (myCellRow == IndexPath.row) //YES!
  17.        
  18. #define myTag 5
  19.        
  20. UITableViewCell *myCell = ...
  21. myCell.tag = myTag
  22.        
  23. UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
  24. if (selectedCell.tag == myTag) //YES!
  25.        
  26. tableview : didselectRow