0

iOS アプリ用の Facebook ログイン ページを作成しようとしていますが、LoginViewController の IBOutlet が UIActivityIndi​​catorView に接続しようとすると壊れ続けます。これが私が得るエラーです:

2013-12-10 00:29:11.062 uConnect[2254:70b] *キャッチされない例外 'NSUnknownKeyException' が原因でアプリを終了しています。理由: '[ setValue:forUndefinedKey:]: このクラスはキー ローダーのキー値コーディングに準拠していません.'

これが私のインターフェースです

@interface UConnectLoginViewController : UIViewController
-(void)loginFailed;
@property (strong, nonatomic) IBOutlet UIActivityIndicatorView* loader;
@end

ここに私の実装があります

@interface UConnectLoginViewController ()
-(IBAction)performLogin:(id)sender;


@end

@implementation UConnectLoginViewController
@synthesize loader;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(IBAction)performLogin:(id)sender
{
    [self.loader startAnimating];
    UConnectAppDelegate* appDelegate = [UIApplication sharedApplication].delegate;
    [appDelegate openSession];
}

-(void)loginFailed
{
    [self.loader stopAnimating];
}
@end

xib ファイルでは、既に Outlet をビューに接続しています。

編集:

Here is the full console error log:
2013-12-10 18:02:13.830 uConnect[3596:70b] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UConnectLoginViewController 0x8a8c4a0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key spinner.'
*** First throw call stack:
(
    0   CoreFoundation                      0x017b85e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0153b8b6 objc_exception_throw + 44
    2   CoreFoundation                      0x018486a1 -[NSException raise] + 17
    3   Foundation                          0x011fc9ee -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    4   Foundation                          0x01168cfb _NSSetUsingKeyValueSetter + 88
    5   Foundation                          0x01168253 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 267
    6   Foundation                          0x011ca70a -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 412
    7   UIKit                               0x0054ba15 -[UIRuntimeOutletConnection connect] + 106
    8   libobjc.A.dylib                     0x0154d7d2 -[NSObject performSelector:] + 62
    9   CoreFoundation                      0x017b3b6a -[NSArray makeObjectsPerformSelector:] + 314
    10  UIKit                               0x0054a56e -[UINib instantiateWithOwner:options:] + 1417
    11  UIKit                               0x003bc605 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
    12  UIKit                               0x003bcdad -[UIViewController loadView] + 302
    13  UIKit                               0x003bd0ae -[UIViewController loadViewIfRequired] + 78
    14  UIKit                               0x003bd5b4 -[UIViewController view] + 35
    15  UIKit                               0x003ccab9 -[UIViewController shouldAutorotate] + 36
    16  UIKit                               0x003cce01 -[UIViewController _preferredInterfaceOrientationForPresentationInWindow:fromInterfaceOrientation:] + 297
    17  UIKit                               0x006515e5 -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:] + 2330
    18  UIKit                               0x003c90fc -[UIViewController presentViewController:withTransition:completion:] + 6433
    19  UIKit                               0x003c961f -[UIViewController presentViewController:animated:completion:] + 130
    20  uConnect                            0x00002c7a -[UConnectAppDelegate showLoginView] + 218
    21  uConnect                            0x000029b7 -[UConnectAppDelegate application:didFinishLaunchingWithOptions:] + 647
    22  UIKit                               0x002a3355 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 309
    23  UIKit                               0x002a3b95 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1536
    24  UIKit                               0x002a83a8 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 824
    25  UIKit                               0x002bc87c -[UIApplication handleEvent:withNewEvent:] + 3447
    26  UIKit                               0x002bcde9 -[UIApplication sendEvent:] + 85
    27  UIKit                               0x002aa025 _UIApplicationHandleEvent + 736
    28  GraphicsServices                    0x0375f2f6 _PurpleEventCallback + 776
    29  GraphicsServices                    0x0375ee01 PurpleEventCallback + 46
    30  CoreFoundation                      0x01733d65 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
    31  CoreFoundation                      0x01733a9b __CFRunLoopDoSource1 + 523
    32  CoreFoundation                      0x0175e77c __CFRunLoopRun + 2156
    33  CoreFoundation                      0x0175dac3 CFRunLoopRunSpecific + 467
    34  CoreFoundation                      0x0175d8db CFRunLoopRunInMode + 123
    35  UIKit                               0x002a7add -[UIApplication _run] + 840
    36  UIKit                               0x002a9d3b UIApplicationMain + 1225
    37  uConnect                            0x000026fd main + 141
    38  libdyld.dylib                       0x01df670d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

出力に記載されているアプリ デリゲート コード:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch. WE CHECK IF THEY ARE ALREADY LOGGED IN OR NOT.
    self.mainViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"UconnectViewController"];
    self.navigationController = [[UINavigationController alloc]
                                 initWithRootViewController:self.mainViewController];
    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
        // Open the session
        [self openSession];
    } else {
        //Display login view
        [self showLoginView];
    }
    return YES;
}

その他の機能はこちら。

-(void)showLoginView
{
    UIViewController *topViewController = [self.navigationController topViewController];
    UIViewController *presentedViewController = [topViewController presentedViewController];

    //-If login screen is not displayed display it.
    //-If the login screen is displayed and we come back here then login failure.
    //-Update UI if the second happens
    if (![presentedViewController isKindOfClass:[UConnectLoginViewController class]]) {
        UConnectLoginViewController* login = [[UConnectLoginViewController alloc] initWithNibName:@"UConnectLoginViewController" bundle:nil];
        [topViewController presentViewController:login animated:NO completion:nil];
    } else {
        UConnectLoginViewController* login = (UConnectLoginViewController*) presentedViewController;
        [login loginFailed];
    }
}
4

1 に答える 1

2

OK、おそらく問題は、Info.plist に「URL タイプ」を入れるのを忘れていることです

  • Info.plist を開きます
  • URL タイプ キーを追加します (ドロップダウンから取得します)。
  • これにより、1 つのディクショナリ タイプ アイテムの配列が追加されます
  • 辞書のドロップダウンから「URL スキーム」配列を選択します
  • これにより、「URL スキーム」配列が追加されます
  • 「URL スキーム」配列に「fb{YourFBAppId}」を含む文字列を追加します

これがあなたに役立つことを願っています4

于 2015-02-11T12:43:36.890 に答える