2015-01-27 2 views
0

SWRevealViewController를 사용하여 사용자가 현재 어떤 탭에 있는지에 따라 다른 내용을 표시하는 사이드 메뉴를 가져옵니다. 나는 사용자 위치를 알아 내기 위해 AppDelegate이라는 위치에 전역 변수를 만들었습니다.SWRevealViewController 현재보기를 기반으로 한 다른 내용

- (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 문으로 작동하는 것 같군,하지만 메뉴와 메뉴 2에 대한 내용은 아직 변경되지 않습니다 : 내 사이드 ​​바, 나는 내용을 변경하려면이 조건을 사용하고 있습니다. 내가 어디로 잘못 가고 있니?

+0

메뉴에서 무엇을하고 있습니까? – ColdSteel

+0

ar [당신의 tableview Name reloadData]를 추가하십시오; after ** ** ** –

+0

if 문을 닫은 후에 [self.tableView reload]를 추가하지 않았습니다. 고맙습니다! – lulu12345609876

답변

0

나는 끊임없이 다시로드 셀,하지만 테이블을 주도하는 (은 if 문을 닫은 후

[self.tableView reload]; 

을 추가하고, 대신 cellForRowAtIndexPath 아래를 추가 할 수 없습니다 - 나의 이해가 정확한지 .)

if 문을 닫고 문제가 해결 된 후 viewWillAppear에 추가되었습니다.

Anbu.Karthik 덕분에!

관련 문제