【发布时间】:2011-11-21 03:05:47
【问题描述】:
我无法更新我的tableView。
rootviewcontroller管理的popover的tableView中,显示了我的文档目录中的一些项目。在detailViewcontroller 中,我使用NSFilemanager 更改了这些文件的名称。无论我做什么,tableView 都不会显示新的。如果我关闭应用程序并再次打开它,我会看到它们。目前,我尝试使用通知,但它不起作用……
编辑
我记录了我的文档目录,肯定不是tableView的问题,而且效果很好,但是第二次输入一些文本,什么都没有发生……
DetailViewController
- (void)textFieldDidEndEditing:(UITextField *)tf
{
textLabel.text = textField.text;
NSString* newName = textLabel.text;
newName = [newName stringByAppendingPathExtension:@"txt"];
NSString* newPath = [[currentFilePath stringByDeletingLastPathComponent] stringByAppendingPathComponent:newName];
NSLog(@"%@",newPath);
[[NSFileManager defaultManager] moveItemAtPath:currentFilePath toPath:newPath error:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"DataSaved" object:nil];
}
RootViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView initWithFrame:self.tableView.frame style:UITableViewStyleGrouped];
self.clearsSelectionOnViewWillAppear = NO;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dataSaved:) name:@"DataSaved" object:nil];
}
- (void)dataSaved:(NSNotification *)notification
{
[self loadDirectoryContents];
[self.tableView reloadData];
}
【问题讨论】:
-
哦 loadDirectoryContents 效果很好顺便说一句
标签: ios ipad file uitableview reload