English 中文(简体)
Overriding UITableViewController s cellForRowAtIndexPath in Target-C
原标题:Overriding UITableViewController s cellForRowAtIndexPath in Objective-C

I have a view controller MainVC which contains a view where I want to switch between various tables. I have an "abstract" class called InfoVC which extends UITableViewController and contains several methods that must be overridden or else they throw an exception. Finally, I have several classes which extend InfoVC and implement the "abstract" methods in InfoVC, along with methods that override tableView s numberOfRowsInSection and cellForRowAtIndexPath.

This is how I load a table in MainVC. In this case, TemperatureInfoVC extends InfoVC, self.subVC is of type InfoVC, and switchView is a view in MainVC:

TemperatureInfoVC *sVC = [[TemperatureInfoVC alloc] initWithStyle:UITableViewStylePlain];
self.subVC = sVC;
[sVC release];
[switchView insertSubview:self.subVC.view atIndex:0];

我的问题是,表格总是空洞的。 从定点到点,我可以看到,“温度信息”栏号是“OfRowsIn”栏,但“温度信息”或“IndexPath”号都不叫。 然而,如果我把上述法典的第一行改为:

InfoVC *sVC = [[InfoVC alloc] initWithStyle:UITableViewStylePlain];

然后,InfoVC的编号OfRowsInsection and cellForRowAtIndexPath被适当称为。 是否有任何人知道为什么没有叫TyratureInfoVC的L.ForRowAtIndexPath?

最佳回答

Oops, 引出。 我正在把位于NentVC的一架NSMutableArray中的数据装上中,但我正在把数据放在I初始化分VC之前,因此该表当然没有数据。

问题回答

我假定,你没有指定代表(可调用的电文)和数据来源(可调用的电文)。 通常,该代表和数据来源的实施都是按惯例使用可调用的电算盘,因此(如果IB没有接线),需要这样一些地方:

tableView.delegate = self;
tableView.dataSource = self;

often within the -loadView or -viewDidLoad:





相关问题
Is it possible to override a non-virtual method?

Is there any way to override a non-virtual method? or something that gives similar results (other than creating a new method to call the desired method)? I would like to override a method from ...

Is is possible to override a hidden method?

Say I have the following hierarchy: public class MyClass { protected virtual void Method() { ... } } public class MySubClass : MyClass { public new virtual void Method() { ... } } public class ...

C++ : implications of making a method virtual

Should be a newbie question... I have existing code in an existing class, A, that I want to extend in order to override an existing method, A::f(). So now I want to create class B to override f(), ...

Override Events in VB.NET

I would like to shadow/override an event in VB.NET. I do it only because I have to implement in this object an interface, that contains the same event like the base object itself, and I need to keep ...

Count calls to eval

I would like to count the number of calls made to eval in our javascript application. I came up with the following, but it generates errors. These errors are hard to track, and my knowledge of the ...

JavaScript: Overriding alert()

Has anyone got any experience with overriding the alert() function in JavaScript? Which browsers support this? Which browser-versions support this? What are the dangers in overriding the function?

热门标签