解决方案 »
- 多个viewcontroller放置在一起,手势处理不能响应
- 没有苹果的ID就不能下载IOS的SDK开发包吗?
- 请教一个UITableView改变大小的问题
- iOS音频裁剪或者播放裁剪片段
- UI页面效果图,请分析一下View的设计和布局控件。
- ZBarSDK iphone5s 真机测试cpu占用不返还
- tableview 重用问题
- Plist文件
- 实现用按钮控制产生随机数 求大神
- 适配iOS10 3D Touch出现多余的条目和Widget
- 急急急!!!同一个tableViewController的headerView上有个segmentControl,想用来实现本页面上tableView的切换!
- 请教关于 Struct 结构体的问题
{
[self.dicarray removeObjectAtIndex:[indexPath row]];
[tableView deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
}
不需要reloadData吧
if(editingStyle==UITableViewCellEditingStyleDelete)
{
[self.dicarray removeObjectAtIndex:[indexPath row]];
[self.tableView beginUpdates];
[self.tableView deleteRowsAtIndexPaths:@[indexPath]
withRowAnimation:UITableViewRowAnimationAutomatic];
[self.tableView endUpdates];
}在删除行是有动画效果,如果你的数据源及UI都实际已经移除掉了该行,后面也就没必要再重新reloadData
NSMutableArray *Variablearray=[NSMutableArray arrayWithArray:self.dicarray];
if(editingStyle==UITableViewCellEditingStyleDelete)
{
[Variablearray removeObjectAtIndex:[indexPath row]];
[self.tableview deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
问题在于所有从NSUserDefaults返回的值全部是immutable(不可变)的,所以在修改数组时会出现这个问题。你可以尝试在使用self.dicarray之前先实例化一下
self.dicarray =[[NSMutableArray alloc] initWithCapacity:0];
之后的其它代码不变,再运行试试
NSUserDefaults *Store_Update = [NSUserDefaults standardUserDefaults];
id jsonObject=[Store_Update objectForKey:@"json"];
if ([jsonObject isKindOfClass:[NSDictionary class]])
{
NSMutableDictionary *dictionary = [NSMutableDictionary dictionaryWithDictionary:jsonObject];
NSMutableArray *dicarray=[dictionary objectForKey:@"Name"];
self.Variablearray=[NSMutableArray arrayWithArray:dicarray];
}else
{
NSLog(@"ぶしで");
}
删除的问题已经解决了,取值的时候转一下就好了,这样还是存在问题,删除后再次返回到这个页面数据没更新。
ok,解决了。 NSMutableDictionary *jsdiction=[[NSMutableDictionary alloc]init];
[jsdiction setValue:self.Variablearray forKey:@"Name"];
NSLog(@"======jsdiction:%@\nVariablearray:%@",jsdiction,self.Variablearray);
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setObject:jsdiction forKey:@"json"];
[userDefaults synchronize];