我的主视图中的弹出框内有一个表格 View ,它是一个网络浏览器。每当用户访问一个网页时,我希望它将该页面添加到最近访问过的网站列表中。我设置了代码以将 URL 作为字符串添加到作为表格 View 的数据源的数组中。表格 View 仅显示访问的第一个站点,并且不会显示任何内容。但是我知道这些站点正在添加到数组中,因为该数组在添加后使用 NSLog 语句显示站点。但是它们仍然不会出现在表格中。谁能帮我?
编辑:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return [recentlyVisitedUrls count];
}
最佳答案
还要确保从 – tableView:numberOfRowsInSection:
返回数组的正确长度。
关于objective-c - 将对象添加到数组后,tableview 不会更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8857272/