iPhone开发技巧之私有API(2)--- UITableView
2011-05-17 21:41
381 查看
像下面 UITableView 中实现复数选择的设置,需要用到 Undocumented API。
首先,如下所示,在实现了 UITableViewDelegate 的类中实现下面的方法。
其中 UITableViewCellEditingStyle 的定义在 SDK 中如下所示:
也就是说,我们使用了私有的TableView风格。另外取得被选择的item可以使用 indexPathsForSelectedRows 方法,该方法也也是私有的。
另外,我们也可以使用公开的方法来一个一个的选择/解除cell,而不用使用私有API。
首先,如下所示,在实现了 UITableViewDelegate 的类中实现下面的方法。
1 2 3 4 | - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return 3; } |
1 2 3 45 | typedef enum { UITableViewCellEditingStyleNone, UITableViewCellEditingStyleDelete, UITableViewCellEditingStyleInsert } UITableViewCellEditingStyle; |
1 | - (NSArray *)indexPathsForSelectedRows; |
1 2 3 4 | - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath; - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; - (NSIndexPath *)tableView:(UITableView *)tableView willDeselectRowAtIndexPath:(NSIndexPath *)indexPath; - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath; |
相关文章推荐
- iPhone开发技巧之私有API--- UITableView
- iPhone开发技巧之私有API(2)--- UITableView
- iPhone开发技巧之私有API--- UIBarButtonItem
- iPhone开发技巧之私有API--- UIBarButtonItem
- iPhone开发技巧之私有API--- UISegmentedControl
- iPhone开发技巧之私有API(4)— UIBarButtonItem
- iPhone开发技巧之私有API(6)--- 设置UIWebView中的User-Agent
- iPhone开发技巧之私有API--- UIBarButtonItem
- iPhone开发技巧之私有API(1) --- 设备相关信息
- iPhone开发技巧之私有API(3)--- UIButton
- iPhone开发技巧之私有API--- 设置UIWebView中的User-Agent
- iPhone开发技巧之私有API--- 用UIWebView访问BASIC认证的页面
- iPhone开发技巧之私有API(3)--- UIButton
- iPhone开发技巧之私有API(4)--- UIBarButtonItem
- iPhone开发技巧之私有API--- UIApplication
- iPhone开发技巧之私有API(5)--- UISegmentedControl
- iPhone开发技巧之私有API(6)--- 设置UIWebView中的User-Agent
- iPhone开发技巧之私有API — 设备相关信息
- iPhone开发技巧之私有API(7)--- 用UIWebView访问BASIC认证的页面
- iPhone开发技巧之私有API(8)--- UIApplication