【问题标题】:SWRevealViewController Different Content based on Current ViewSWRevealViewController 基于当前视图的不同内容
【发布时间】: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


【解决方案1】:

我没有添加

[self.tableView reload]; 

在关闭 if 语句后,改为将其添加到 cellForRowAtIndexPath 下(这会导致单元格不断重新加载,但不会导致表格 - 如果我的理解正确的话。)

在关闭我的 if 语句并解决问题后将其添加到 viewWillAppear

感谢Anbu.Karthik指出!

【讨论】:

    猜你喜欢
    • 2015-07-03
    • 2017-05-24
    • 2016-09-02
    • 1970-01-01
    • 2019-06-15
    • 2015-11-14
    • 1970-01-01
    • 2018-08-23
    • 1970-01-01
    相关资源
    最近更新 更多