【发布时间】:2012-06-22 20:04:47
【问题描述】:
当我添加新行时,它当前会添加一个以当前日期为标题的新行。以下是我拥有的代码。我应该将“NSDate 日期”更改为什么,以便用户可以输入他们想要的任何标题?
(void)insertNewObject:(id)sender
{
if (!_objects) {
_objects = [[NSMutableArray alloc] init];
}
[_objects insertObject:[NSDate date] atIndex:0];
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0];
[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
【问题讨论】:
-
看起来您已经在 Xcode 中生成了默认的 MasterViewController 项目。我建议搜索有关 UITableView 的教程,或者阅读有关 iOS 开发的书。也许有人可以推荐一个。