2009-08-22 60 views
0

我正在使用iPhone應用程序,但我需要能夠添加東西到UITableView ... 這是什麼最簡單的方法?添加到UITableView

易怒

回答

1

如果你使用的是由一個NSMutableArray(或NSArray的)支持的一個UITableViewController,那麼你必須做的第一件事是添加新對象到你的陣列是這樣的:

[objects addObject:obj]; 

然後調用

[tableView reload] 

這將導致tableView:numberOfRowsInSection:進行檢查。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
    return [objects count]; 
} 

最後,tableView:cellForRowAtIndexPath:將被調用,你可能已經寫入處理渲染單元。