I am using CAPSPageMenu with 2 tabs. Now there is an button at right bar button. When ever i click that i have an view with one button called sayHello
. Now when i click that button i needs to know which tab i was in. That bar button is for both tabs.But how can i check which tab was i am when i click on that sayHello
.
code :
In my homevc
i added that two tabs .
VC1, VC2
..
And i tried in viewwillAppear added on bool in nsuserdefault
and tried to fetch. But that bool is always coming as TRUE
. Which ever tab i am - still the bool values i coming as true.Here is an code :
In vc1
-(void)viewWillAppear:(BOOL)animated {
userDefault = [NSUserDefaults standardUserDefaults];
[userDefault setBool:TRUE forKey:@"fromVC1"]; // Tried true, YES also
NSLog(@"from vc1");
}
In vc2
-(void)viewWillAppear:(BOOL)animated {
userDefault = [NSUserDefaults standardUserDefaults];
[userDefault FALSE forKey:@"fromVC1"]; // Tried false, No also
NSLog(@"from vc1");
}
And i am checking like :
BOOL Val;
userDefault = [NSUserDefaults standardUserDefaults];
Val = [userDefault objectForKey:@"fromVC1"];
if (Val) {
NSLog(@"from VC1");
}else {
NSLog(@"from VC2");
}
But always its coming as True
. Any idea how to get that ?Which tab i was i before. when i press my button sayHello
.
- (void)didTapGoToLeft {
NSInteger currentIndex = self.pageMenu.currentPageIndex;
if (currentIndex > 0) {
[_pageMenu moveToPage:currentIndex - 1];
}
}
//
- (void)didTapGoToRight {
NSInteger currentIndex = self.pageMenu.currentPageIndex;
if (currentIndex < self.pageMenu.controllerArray.count) {
[self.pageMenu moveToPage:currentIndex + 1];
}
}