2010-09-15 44 views
1

我有這樣的:在UIViewController UITableView,數據源的問題?

@interface HomePage : UIViewController<UITableViewDelegate, UITableViewDataSource> { 
UITableView *myTable; 
NSMutableArray *data; 
} 
@property (nonatomic, retain) IBOutlet UITableView *myTaböe; 
@property (nonatomic, retain) NSMutable *data; 

,然後我已經通過IB的myTable的連接,在「文件的所有者」數據源和委託。 我然後將數據初始化爲viewDidLoad方法中的空數組。

我執行HTTP調用後檢索一些數據,將項目添加到數據:

int i= 0; 
    while(barfoo is true){ 
     [data insertObject:r atIndex:i]; 
     NSArray *insertIndexPaths = [NSArray arrayWithObjects:[NSIndexPath indexPathForRow:i inSection:0],nil]; 
     UITableView *tv = (UITableView *)self.myTable; 
     [tv beginUpdates]; 
     [tv insertRowsAtIndexPaths:insertIndexPaths withRowAnimation:UITableViewRowAnimationRight]; 
     [tv endUpdates]; 
    i++; 
    } 

,但什麼也沒發生.....爲什麼呢?

回答

0

我猜這是因爲你正在更新tv表,而你的視圖實際上顯示的是myTable。我沒有看到代碼的相關部分,但要確保你的UIView實際上使用了正確的表格。另外,如果這會給你帶來任何地方,試圖在某處添加[myTable reloadData]或[tv reloadData]。但我認爲問題在第一段 - 如果這不起作用,我不明白爲什麼這應該...