selectedIndex UItabBarController not working
I know this is gonna be an easy fix, but for some reason when i try to fix
my issue with other solutions, it just doesnt work. In my app I set up
Push Notifications, and I'm trying to set up the functionality of opening
the app to a certain tabBarItem when the app is opened from a
Notifications. here is the code i have so far, please tell me if I'm even
using the right method. I'm not very experienced with AppDelegate.m so
please forgive me if its completely wrong.
AppDelegate.m
#import <CoreLocation/CoreLocation.h>
@interface AppDelegate : UIResponder
<UIApplicationDelegate,UITabBarControllerDelegate,CLLocationManagerDelegate>{
CLLocationManager *locationManager;
}
@property (strong, nonatomic) UIWindow *window;
@property(nonatomic,readonly) UITabBar *tabBar;
@property(nonatomic,strong) UITabBarController *tabBarController;
@end
AppDelegate.m
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIApplication* app = [UIApplication sharedApplication];
app.networkActivityIndicatorVisible = YES;
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)];
return YES;
}
- (void)application:(UIApplication*)application
didReceiveRemoteNotification:(NSDictionary*)userInfo{
/* this works just fine*/
NSLog(@"opening from a notification!!");
/*this is what doesnt work at all*/
self.tabBarController = [[UITabBarController alloc] init];
[self.tabBarController ];
self.tabBarController.selectedIndex = 3;
/*also when i do nslog the selectedIndex it gives me this value
"2147483647"*/
NSLog(@"%i is the tabbar item",tabBarController.selectedIndex);
}
No comments:
Post a Comment