2013-01-17 38 views
0

我有一個自定義視圖EMViewController與一個tableview作爲子視圖。我希望EMViewController作爲子視圖的控制器,所以我將它設置爲委託和數據源。ios6 - numberOfRowsInSection不會運行自定義tableviewcell,委託/數據源集

// EMViewController.h 
@interface EMViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> 
... 
// EMViewController.m 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.eTableView.delegate = self; 
    self.eTableView.dataSource = self; 
} 

我正與來自Facebook異步陣列/字典填充數據,所以一旦我有數據,我運行

[self.eTableView reloadData] 

對於UITableViewDataSource協議方法,我實現以下內容:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    NSLog(@"returns sections 0"); // This appears in my log 
    return 0; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    NSLog(@"returning count %d", [self.eList count]); // never shows up 
    return [self.eList count]; 
} 

- (EMTableViewCell *)tableView:(EMTableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    // configure the cell 
    NSLog(@"index: %d", indexPath); // never shows up 
    ... 
} 

到目前爲止,我已經嘗試:

  • 使確保我的故事板連接起來
  • 檢查/複查委託/數據源在viewDidLoad中被設置
  • 完全重啓/清除構建我的應用程序,以防萬一
  • 創建一個佔位符UIView子類(雖然我沒有太大變化)
  • 創建customUITableViewCell類網點爲我的自定義佈局(圖像,3個標籤)
  • 測試了強/弱引用到的tableView出口

任何意見,將不勝感激。我認爲我的問題類似於this question,除了我試圖添加tableview作爲子視圖。我的最終目標是使用包含圖像和三個標籤的自定義格式填充單元格。謝謝!

+0

請出示dequence碼 –

回答

2

返回1段,而不是返回0部分

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    return 1; 
} 
+0

或者,只是沒有實現這些方法都沒有。默認值爲1. – rdelmar

+0

愚蠢的meeeeee。我認爲自動生成的存根的評論說,返回0是1節的默認值。作爲後續,我如何訪問我爲原型單元格構建的故事板元素? – myclues