开发者

Passing info from Facebook to UITabBarController

开发者 https://www.devze.com 2023-02-08 09:48 出处:网络
When my app first starts, it shows a main page to log in to Facebook.Then, it goes to the UITabBarController. The code that I have in my app delegate is the following:

When my app first starts, it shows a main page to log in to Facebook. Then, it goes to the UITabBarController. The code that I have in my app delegate is the following:

//this is the .h
@interface NMeAppDelegate : NSObject <UIApplicationDelegate> {
    UIWindow *开发者_如何学编程window;
    MainViewController *controller;
    UITabBarController *tabBar;
}

@property (nonatomic, retain) IBOutlet UITabBarController *tabBar;
@property (nonatomic, retain) MainViewController *controller;
@property (nonatomic, retain) IBOutlet UIWindow *window;

@end

//this is the .m of the app delegate
#import "NMeAppDelegate.h"

@implementation NMeAppDelegate

@synthesize window;
@synthesize tabBar;
@synthesize controller;

#pragma mark -
#pragma mark Application lifecycle

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    // Override point for customization after application launch.
    controller = [[MainViewController alloc] init];
    [window addSubview:tabBar.view];
    [window addSubview:controller.view];
    [window makeKeyAndVisible];

    return YES;
}

Inside of MainViewController, I actually have a UserInfo object, which has all of the information that I need for the UITabBarController. The problem is that after getting this info in the UITabViewController, how do I pass this UserInfo to the UITabBarController` or possible the ViewController that is inside the UITabBarController so they were able to access this UserInfo? How to do this?

I hope my question makes sense.


you need to have an instance of your UserInfo object available to the tab bar controller. probably pass it into a instance variable of type UserInfo in your UItabBarController/each view controller whenever you transition into the specified controller.

edit: you should really have this passed into the view Controller it needs to be in (since it doesn't appear you have a custom UITabBarController subclass), or you could use a shared UserInfo variable in your app delegate to keep up with the information.

But as the commenter said, the question is not very clear at all and i could be completely misunderstanding what you want to do.

Hope that helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消