2010-11-22 4 views
0

Je suis en train de créer une application qui nécessite à la fois un contrôleur de vue et un contrôleur de barre d'onglets. Lorsque je démarre l'application, il faut charger le contrôleur de vue (qui est l'écran de connexion) et à partir de là, je dois aller à la vue du contrôleur de la barre d'onglets où l'application commence réellement.basculer entre viewcontroller et le contrôleur de la barre d'onglets

Voici ce que j'ai essayé:

appdelegate.h

#import <UIKit/UIKit.h> 

@interface IeAppDelegate 
     : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> { 

    UIWindow *window; 

    UITabBarController *tabBarController; 

    UIViewController *LoginController; 
} 

@property (nonatomic, retain) IBOutlet UIWindow *window; 

@property (nonatomic, retain) IBOutlet UITabBarController *tabBarController; 

@property (nonatomic, retain) IBOutlet UIViewController *LoginController; 

@end 

appdelegate.m

@synthesize window; 

@synthesize tabBarController; 

@synthesize LoginController; 

#pragma mark - 
#pragma mark Application lifecycle 

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

    // Override point for customization after application launch. 

    // Add the tab bar controller's view to the window and display. 

    LoginController = [[LoginController alloc] init]; 
    [window LoginController.view]; 

    [window addSubview:tabBarController.view]; 
    [window makeKeyAndVisible]; 

    return YES; 
} 

Je reçois ces erreurs et avertissements. Qu'est-ce que je fais mal?

 
warning: 'UIViewController' may not respond to '-alloc' 
warning: (Messages without a matching method signature 
warning: will be assumed to return 'id' and accept 
warning: '...' as arguments.) 
error: expected ']' before '.' token 
warning: 'UIWindow' may not respond to '-LoginController' 

Mise à jour: Je compris une erreur:

LoginController = [[LoginViewController alloc] init]; 

Mais dans cette déclaration:

[window LoginController.view]; 

-je encore:

error: expected ']' before '.' token

Répondre

0

Commencez avec une application de tabulation. Dans la partie applicationDidFinishLaunchingWithOptions de votre délégué d'application, vous ajoutez votre viewcontroller à la fenêtre, masquant la barre d'onglets et tout le reste. Cela ressemblera à ceci:

// Initialize your login view controller 
yourLoginViewController = [[YourLoginViewController alloc] init]; 

// Add in the tab controller 
// (this code should already be there if you started with the template) 
[window addSubview:tabcontroller.view]; 

// In front of that add in your login view controller 
[window yourLoginViewController.view]; 

// Finally, display the whole thing (this should also already be there) 
[window makeKeyAndVisible]; 
Questions connexes