我有一个view
,其中UITabelView
有可移动的行,用于调整我view
内不同ViewController
的按钮。
移动行时,view
中的图标应更新。见下文(注意[self refreshicons]
):
-(void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath{
NSInteger sourceRow = sourceIndexPath.row;
NSInteger destRow = destinationIndexPath.row;
id object = [shortcutApps objectAtIndex:sourceRow];
[shortcutApps removeObjectAtIndex:sourceRow];
[shortcutApps insertObject:object atIndex:destRow];
[tableView reloadData];
[self refreshIcons];
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:shortcutApps forKey:@"ShortcutArray"];
}
这是[self refreshicons]
-(void)refreshIcons{
icon1 = [shortcutApps objectAtIndex:0];
NSLog(@"%@",icon1);
[extraIcon1 setImage:[UIImage imageNamed:[[icon1 lowercaseString] stringByReplacingOccurrencesOfString:@" " withString:@""]] forState:UIControlStateNormal];
extraIconLabel1.text = icon1;
NSLog(@"%@",extraIconLabel1);
}
NSLogs打印正确的字符串,但UILabel和UIButton图像不会更新。当创建一个按钮,在同一个[self refreshicons]
中存在与view
相同的代码时,代码会按照需要运行。但是当移动行或在view
外按下按钮时,标签和按钮不会更新。
想法?
答案 0 :(得分:0)
似乎tableview:cellForRowAtIndexPath:
方法中发生的任何事情都会覆盖您的图标。
我猜的refreshIcons
中的引用是指您保留的以便快速更新值的引用,但它们可能会通过reloadData
周期。