I have an app that is a TabBarControllers with 4 tabs. Now, in didFinishLaunchingWithOptions I did this:
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)];
lpgr.minimumPressDuration = 5.0;
lpgr.delegate = self;
[self.window addGestureRecognizer:lpgr];
[lpgr release];
This part is working and the long press gesture is recognize in all the four tabs. Now, I want to pass the name of the current ViewController that the user is currently pressing on so I can pass it in my function that handles the long press event.
You can try:
NSStringFromClass([YourViewController class]);
and for current view controller, use:
NSStringFromClass([self class]);
Try Below One(Updated)
AS you Told you have added Four ViewController on TabBar Controller.
Get The ViewController from TabBarController As:
UIViewController *current = tabBarController.selectedViewController;
NSArray *controllerNameArray = [current childViewControllers];
NSLog(@"className %@",[controllerNameArray objectAtIndex:0]);
I Hope It really Helpful to you...!!!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With