2012-09-21 18 views
0

我創建了一個新的View控制器,並添加了「Table View」。 我添加了出口到控制器代碼和viewDidLoad方法我試圖添加一個新行。UITableView在應用程序運行時添加行

我有簡單的數據源NSMutableArray與文本(表是類似「名人堂」)。

如何從數組中插入帶有文本的行?

@property (strong, nonatomic) IBOutlet UITableView *fameTable; 
@property (weak, nonatomic) NSMutableArray *dataSource; 
... 
[self.dataSource addObject:@"New Item"]; 
[self.dataSource addObject:@"New Item 2"]; 
[self.dataSource addObject:@"New Item 3"]; 

回答

0
after adding is done .. 

    [fameTable reloadData]; 

dont forget to implement the datasource method 

    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 

    return [datasource count]; 

    }