我一直在尝试按照本教程访问 UITableView 类中 UITableView 的一些实例方法,以使用 NSFetchedResultsController http://www.raywenderlich.com/999/core-data-tutorial-how-to-use-nsfetchedresultscontroller
在教程中有一段代码,您可以在其中访问 self .tableView,这是有道理的,因为您使用的是 UITableViewController。但是,我正在尝试使用 UITableView,但找不到任何使用它的示例。
查看文档,我应该有一个实例方法“beginUpdates”(reloadUpdates、insertRowsAtIndexPaths:withRowAnimation:)
http://developer.apple.com/ library/ios/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html
但是,当我尝试使用 [self beginUpdates] 访问实例方法时,我无法获取实例方法(找不到方法)。对于许多实例方法来说都是如此,但不是全部。例如,我可以访问
[self setEditing:(BOOL) animated:(BOOL)]
我对 Objective-C 相当陌生,所以我相信我正在以错误的方式访问我的 UITableView 实例,但我对该类唯一能想到的就是“self”
我该怎么办访问 UITableView 而不是 UITableViewController 中的那些方法?
I've been trying to access some instance methods of UITableView inside my UITableView class to use a NSFetchedResultsController following this tutorial http://www.raywenderlich.com/999/core-data-tutorial-how-to-use-nsfetchedresultscontroller
In the tutorial there is a section of code where you're accessing self.tableView, which makes sense because you're using a UITableViewController. However, I am trying to use a UITableView and I can't find any examples that use that.
Looking at the documentation, I should have an instance method "beginUpdates" among other things (reloadUpdates, insertRowsAtIndexPaths:withRowAnimation:)
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html
However, when I try to access the instance method with [self beginUpdates] I can't get the instance method (Method not found). It's like that for a bunch of the instance methods, but not all of them. For example, I can access
[self setEditing:(BOOL) animated:(BOOL)]
I'm rather new to Objective-C so I believe I'm accessing my UITableView instance in the wrong fashion, but the only thing I can think of with that class is "self"
How do I go about accessing those methods in UITableView rather than UITableViewController?
发布评论
评论(1)
+1 @Hollance 的评论。您可能会发现您想要自定义视图控制器逻辑的程度超出了
UITableViewController
子类化所允许的范围,但是通过由UIViewController
组成的子类可以更好地实现这一点。 >UITableView(即tableView
出口/属性)。+1 @Hollance's comment. You may find that you want to customize your view controller logic more than subclassing
UITableViewController
allows, but this would be better served by a subclass ofUIViewController
that is composed with aUITableView
(i.e., thetableView
outlet/property).