cellForRowAtIndexPath不被调用(再次)
我已经find了同样的问题,但答案并没有帮助我:(也许是因为我有具体的问题。安装应用程序到iPhone 4S(iOS 5)后出现一些问题,我已经修复了几个,但这一个更顽固这似乎一见钟情。
我在Xcode4中打开了现有的Xcode3项目,出现了这个问题。
我会在这里放一些代码:
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{ // Return the number of sections. return 1; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { // Return the number of rows in the section. return [self.townShopsArray count]; }
我检查:self.townShopsArray不是空的
function:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { ...
没有被调用,所以我不需要把它的代码放在这里。
任何人都可以告诉我,当我从Xcode 3升级到Xcode 4的项目时会出现什么问题?
以下是可能的原因:
- 你的UITableView的数据源没有设置到这个控制器
-
您的UIViewController / UITableViewController的类未设置为Interface Builder的Identity Inspector中此视图控制器的类。 如果没有设置,iOS会询问generics的UITableView类来获取关于你的单元格的信息,而不是你所做的类。
-
(如果你以编程方式添加了UITableView)…你指向表的指针不强,并且UITableView已经被释放