简体   繁体   中英

Location of UITableViewController files

I have multiple tableviews that have various static cells and everything is cool.

I would like to implement some functionality to a button that is in one of the cells in all of the tables, but I do not know where the header and implementation files for UITableViewController are located and or how to access them. Any ideas?

You can't directly manipulate UITableViewController . Besides, it is not a good idea to do it anyway. The best way to do it is subclassing it.

  1. Command+N and create a new NSObject file
  2. When prompted, name it whatever you like (eg MyTableViewController )
  3. Click on MyTableViewController.h in left side pane, and change NSObject to UITableViewController .
  4. Goto the XIB file or the Storyboard (whichever you are using) and change the class of your UITableViewController to MyTableViewController .
  5. Give a number to the button's tag field (eg 1001).
  6. Now, in your MyTableViewController.m class, get a hold of the cell ( cellAtIndexPath: ) and then get a hold of that button with tag ( [cell.contentView viewWithTag:] ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM