2012-07-05 64 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

相關問題