2012-07-05 62 views
0

我的UITableView没有填充因为:UITableView的未填充,因为的tableView:的cellForRowAtIndexPath则永远不会调用

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

永远不会调用。

这是我的初始化表:

self.recentScannedItems = [[[UITableView alloc] initWithFrame:kLastScannedPortrait style:UITableViewStylePlain] autorelease]; 
    [self.recentScannedItems setDelegate:self]; 
    [self.recentScannedItems setDataSource:self]; 
    [self.view addSubview:recentScannedItems]; 

我缺少什么?

+0

你从'numberOfRowsInSection:'返回什么? – 2012-07-05 13:08:15

+0

您确定最近扫描的项目包含某些东西......最有可能它从来没有被称为'因为'numberOfRowsInSection:'返回0计数元素。 – Andrea 2012-07-05 13:16:48

回答

0

您是否正确实施的数据源方法:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)aTableView { 
    // Return the number of sections. 
    return NumberOfSections; 
} 

- (NSInteger)tableView:(UITableView *)aTableView numberOfRowsInSection:(NSInteger)section { 
    // Return the number of rows in the section. 

    return NumberOfRows; 
} 

如果不实现这个方法,或者如果你是在它们返回0,的cellForRowAtIndexPath不会被调用

+0

是的,很好的一个。这是因为行总是0. – aneuryzm 2012-07-05 13:10:13

+0

你可以用这两种方法编辑吗? – JonLOo 2012-07-05 13:12:24

+0

那么解决了? :)。 – JonLOo 2012-07-05 13:14:58

0

您的课程是否符合UITableViewDataSource?像:

@interface mySuperClass : UIViewController <UITableViewDataSource, UITableViewDelegate> 
+0

是的,它符合它。顺便说一句,这只是编译器,它应该工作,即使它失踪我相信。尚未解决... – aneuryzm 2012-07-05 13:10:51

相关问题