0

我创建了一个新的视图控制器并添加了“表格视图”。我将出口添加到控制器代码中,并在 viewDidLoad 方法中尝试添加新行。

我有带有文本的简单数据源 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"];
4

2 回答 2

0

看看表格视图的 insertRowAtIndex 方法..它插入行而不重新加载整个表格视图..在发布此类问题之前请做一个小研究..这是一个非常常见的问题..仍然希望它对您有所帮助!干杯!!

她是一个关于表格视图基础的小教程:

http://www.mobisoftinfotech.com/blog/iphone/introduction-to-table-view/

于 2012-09-21T13:28:29.707 回答
0
after adding is done ..

    [fameTable reloadData];

dont forget to implement the datasource method

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

   return  [datasource count];

    }
于 2012-09-21T13:30:42.687 回答