【发布时间】:2015-03-25 19:00:13
【问题描述】:
我正在使用 SWRevealViewController 来获取侧边菜单,以根据用户当前所在的选项卡显示不同的内容。我在AppDelegate 的被调用位置中创建了一个全局变量,以找出用户所在的位置。对于我的侧边栏,我使用此条件来更改内容:
- (void)viewWillAppear:(BOOL)animated {
[super viewDidAppear:animated];
AppDelegate *del=(AppDelegate*)[[UIApplication sharedApplication] delegate];
if ([del.location isEqualToString: @"Secure"]){
self.menu = [NSMutableArray
arrayWithObjects:@"secure1",@"secure2",@"secure3",@"secure4",@"secure5", nil];
self.menu2 = [NSMutableArray
arrayWithObjects:@"s1",@"s2",@"s3",nil];
NSLog(@"THIS IS %@ menu",del.location);
}
else if ([del.location isEqualToString: @"Employee"]){
self.menu = [NSMutableArray
arrayWithObjects:@"emp1",@"emp2",@"emp3",@"emp4",@"emp5",@"emp6", nil];
self.menu2 = [NSMutableArray
arrayWithObjects:@"e1",@"e2",@"e3",nil];
NSLog(@"THIS IS %@ menu",del.location);
}
else if ([del.location isEqualToString: @"Patient"]){
self.menu = [NSMutableArray
arrayWithObjects:@"patient1",@"patient2",@"patient3",@"patient4",@"patient5",@"patient6", nil];
self.menu2 = [NSMutableArray
arrayWithObjects:@"p1",nil];
NSLog(@"THIS IS %@ menu",del.location);
}
}
似乎NSLog 语句都正确输出,但 menu 和 menu2 的内容仍然没有改变。我哪里错了?
【问题讨论】:
-
你在菜单里做什么?
-
ar u 添加 [您的 tableview 名称 reloadData];在 } 之后
-
我没有在关闭 if 语句后添加 [self.tableView reload]。谢谢!
标签: ios objective-c xcode xcode6 swrevealviewcontroller