我正在开发一个iOS应用程序,其中使用了自定义集合视图。在菜单栏中它有3个控制器1,2,3的列表。当我选择2时,我想创建一个新的集合视图布局并清除前一个。是否可以清除以前的集合视图布局中的数据?集合视图正在以编程方式创建iOS。如何清除集合视图布局上的内容ios
这是我的一段代码。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"indexpath : %ld",(long)indexPath.row);
if(((long)indexPath.row==0) && (indexPath.section==0)){
HelpController *three=[[HelpController alloc] initWithNibName:@"HelpController" bundle:nil];
[ self presentViewController:three animated:YES completion:nil];
// [self.navigationController pushViewController:three animated:YES];
NSLog(@"Help");
}
if(((long)indexPath.row==1) && (indexPath.section==0)){
backupController *bckup=[[backupController alloc]initWithNibName:@"backupController" bundle:nil];
[self presentViewController:bckup animated:YES completion:nil];
// [self.navigationController pushViewController:bckup animated:YES];
NSLog(@"BackUp");
}
if(((long)indexPath.row==2) && (indexPath.section==0)){
NSLog(@"Children");
[self.navigationController dismissViewControllerAnimated:YES completion:nil];
}
if(((long)indexPath.row==3) && (indexPath.section==0)){
AboutusController *three=[[AboutusController alloc] initWithNibName:@"AboutusController" bundle:nil];
[ self presentViewController:three animated:YES completion:nil];
NSLog(@"AboutUS");
}
if(((long)indexPath.row==4) && (indexPath.section==1)){
AddChildViewController *three=[[AddChildViewController alloc] initWithNibName:@"AddChildViewController" bundle:nil];
[ self.navigationController pushViewController:three animated:YES];
NSLog(@"AboutUS");
}
if(((long)indexPath.row==0) && (indexPath.section==1)){
NSString *savedValue = [[NSUserDefaults standardUserDefaults]
stringForKey:@"firstchild"];
[[NSUserDefaults standardUserDefaults] setObject:savedValue forKey:@"childname"];
[[childDBHelper sharedInstance] createDatabase];
AddChildViewController *add =[[AddChildViewController alloc]initWithNibName:@"AddChildViewController" bundle:nil];
[add navigatenext];
// [self.navigationController popToRootViewControllerAnimated:];
[self viewWillAppear:YES];
[self viewDidLoad];
}
if(((long)indexPath.row==1) && (indexPath.section==1)){
NSString *savedValue = [[NSUserDefaults standardUserDefaults]
stringForKey:@"secondchild"];
[[NSUserDefaults standardUserDefaults] setObject:savedValue forKey:@"childname"];
[[childDBHelper sharedInstance] createDatabase];
AddChildViewController *add =[[AddChildViewController alloc]initWithNibName:@"AddChildViewController" bundle:nil];
[add navigatenext];
// [self.navigationController popToRootViewControllerAnimated:];
[self viewWillAppear:YES];
[self viewDidLoad];
}
if(((long)indexPath.row==2) && (indexPath.section==1)){
NSString *savedValue = [[NSUserDefaults standardUserDefaults]
stringForKey:@"thirdchild"];
[[NSUserDefaults standardUserDefaults] setObject:savedValue forKey:@"childname"];
[[childDBHelper sharedInstance] createDatabase];
AddChildViewController *add =[[AddChildViewController alloc]initWithNibName:@"AddChildViewController" bundle:nil];
[add navigatenext];
// [self.navigationController popToRootViewControllerAnimated:];
[self viewWillAppear:YES];
[self viewDidLoad];
}
if(((long)indexPath.row==3) && (indexPath.section==1)){
NSString *savedValue = [[NSUserDefaults standardUserDefaults]
stringForKey:@"fourthchild"];
[[NSUserDefaults standardUserDefaults] setObject:savedValue forKey:@"childname"];
[[childDBHelper sharedInstance] createDatabase];
AddChildViewController *add =[[AddChildViewController alloc]initWithNibName:@"AddChildViewController" bundle:nil];
[add navigatenext];
// [self.navigationController popToRootViewControllerAnimated:];
[self viewWillAppear:YES];
[self viewDidLoad];
}
}
即使部分实现代码如下节一个我的菜单栏没有隐藏和以前的集合视图数据选择索引路径2后在布局仍然存在。
为什么不重新装入乌尔新的数据相同的集合视图 – 2014-12-03 07:52:41
u能告诉我如何shud我重装了新的数据 – user3659166 2014-12-03 08:50:29