iCulture forum | iPhone, iPad,  iPod touch, Apple TV en iOS

iCulture forum | iPhone, iPad, iPod touch, Apple TV en iOS (https://forum.iculture.nl/)
-   Ontwikkelen voor iOS (https://forum.iculture.nl/f133/development/f58/ontwikkelen-voor-ios/)
-   -   Facebook SDK iOS 6 (https://forum.iculture.nl/f133/development/f58/ontwikkelen-voor-ios/122063-facebook-sdk-ios-6-a.html)

JostiTosti 17-07-12 19:01

Facebook SDK iOS 6
 
Hallo,

Ik heb jullie hulp nodig, momenteel volg ik de Facebook SDK tutorial voor iOS.

https://developers.facebook.com/docs/mobile/ios/build/

Na stap drie zou alles moeten werken, hij lijkt het ook te doen. Je komt in het scherm om je app goed te keuren bij facebook. Daarna gaat die terug naar me app en blijft het hangen op een zwart scherm. De view controller wordt niet ingeladen. als foutmelding krijg ik:

"Application windows are expected to have a root view controller at the end of application launch"

Ik werk met iOS6 beta 2 en storyboard. Kan iemand van jullie mij opweeg helpen?

Code:

//
//  AppDelegate.m
//  fbtest
//
//  Created by Joost Pielage on 17-07-12.
//  Copyright (c) 2012 Fontys. All rights reserved.
//

#import "AppDelegate.h"
#import "ViewController.h"

@implementation AppDelegate

@synthesize window = _window, facebook;
@synthesize viewController = _viewController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.
   
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];
   
    static NSString* kAppId = @"475076652518607";
   
    facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:self];
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    if ([defaults objectForKey:@"FBAccessTokenKey"]
        && [defaults objectForKey:@"FBExpirationDateKey"]) {
        facebook.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
        facebook.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
    }
 
    if (![facebook isSessionValid]) {
            [facebook authorize:nil];
        }
   

 
    return YES;
}



// For iOS 4.2+ support
- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url
  sourceApplication:(NSString *)sourceApplication annotation:(id)annotation {
    return [facebook handleOpenURL:url];
}

- (void)fbDidLogin {
    NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
    [defaults setObject:[facebook accessToken] forKey:@"FBAccessTokenKey"];
    [defaults setObject:[facebook expirationDate] forKey:@"FBExpirationDateKey"];
    [defaults synchronize];
   
}
                                                       
- (void)applicationWillResignActive:(UIApplication *)application
{
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application
{
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application
{
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end


Code:

//
//  AppDelegate.h
//  fbtest
//
//  Created by Joost Pielage on 17-07-12.
//  Copyright (c) 2012 Fontys. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "FBConnect.h"

@interface AppDelegate : UIResponder
<UIApplicationDelegate, FBSessionDelegate>{
    UIViewController *viewController;
    Facebook *facebook;
}


@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, retain) Facebook *facebook;
@property (nonatomic, retain) UIViewController *viewController;

@end


Whacko 18-07-12 10:21

ik weet niet of dit het oplost, maar je hebt deze regel in je .m file:
@synthesize window = _window, facebook;

in het voorbeeld is een losse regel voor @synthesize facebook.

En anders heb je misschien in Storyboard je viewcontroller niet goed gekoppeld.


Alle tijden zijn GMT +2. Het is nu 09:31.