2015-01-12 2 views
1

iPhone 응용 프로그램을 개발하고 구문 분석을 통합하고 있습니다. 원래, Parse.com의 스타터 프로젝트. 이 파일은 스토리 보드 대신 xib를 사용했습니다. xib을 삭제하고 스토리 보드를 만든 다음 기본 스토리 보드 파일 이름베이스 : Main_iPhone을 info.plist 파일로 변경했습니다. 그런 다음 뷰 컨트롤러를 드래그하고 해당 뷰 컨트롤러를 가리키는 작은 화살표를 설정했지만 애플리케이션이 시작되면 화면이 검은 색으로 표시됩니다. 무슨 일 이니? 여기 내 AP 위임 코드 : "메인 인터페이스가"스토리 보드의 이름을 포함 않습니다 일반적으로 아래출시시 아이폰 화면이 검은 색입니다.

// 
// ParseStarterProjectAppDelegate.m 
// ParseStarterProject 
// 
// Copyright 2014 Parse, Inc. All rights reserved. 
// 

#import <Parse/Parse.h> 

// If you want to use any of the UI components, uncomment this line 
// #import <ParseUI/ParseUI.h> 

// If you are using Facebook, uncomment this line 
// #import <ParseFacebookUtils/PFFacebookUtils.h> 

// If you want to use Crash Reporting - uncomment this line 
// #import <ParseCrashReporting/ParseCrashReporting.h> 

#import "ParseStarterProjectAppDelegate.h" 


@implementation ParseStarterProjectAppDelegate 

#pragma mark - UIApplicationDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil]; 

    // Instantiate the initial view controller object from the storyboard 
    //self.window.rootViewController = [storyboard instantiateInitialViewController]; 

    // Enable storing and querying data from Local Datastore. Remove this line if you don't want to 
    // use Local Datastore features or want to use cachePolicy. 
    [Parse enableLocalDatastore]; 

    // **************************************************************************** 
    // Uncomment this line if you want to enable Crash Reporting 
    // [ParseCrashReporting enable]; 
    // 
    // Uncomment and fill in with your Parse credentials: 
    [Parse setApplicationId:@"privatecrap" clientKey:@"privatecrap"]; 
    // 
    // If you are using Facebook, uncomment and add your FacebookAppID to your bundle's plist as 
    // described here: https://developers.facebook.com/docs/getting-started/facebook-sdk-for-ios/ 
    // [PFFacebookUtils initializeFacebook]; 
    // **************************************************************************** 

    [PFUser enableAutomaticUser]; 

    PFACL *defaultACL = [PFACL ACL]; 

    // If you would like all objects to be private by default, remove this line. 
    [defaultACL setPublicReadAccess:YES]; 

    [PFACL setDefaultACL:defaultACL withAccessForCurrentUser:YES]; 

    // Override point for customization after application launch. 

    //self.window.rootViewController = self.viewController; 
    //[self.window makeKeyAndVisible]; 

    if (application.applicationState != UIApplicationStateBackground) { 
     // Track an app open here if we launch with a push, unless 
     // "content_available" was used to trigger a background push (introduced in iOS 7). 
     // In that case, we skip tracking here to avoid double counting the app-open. 
     BOOL preBackgroundPush = ![application respondsToSelector:@selector(backgroundRefreshStatus)]; 
     BOOL oldPushHandlerOnly = ![self respondsToSelector:@selector(application:didReceiveRemoteNotification:fetchCompletionHandler:)]; 
     BOOL noPushPayload = ![launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 
     if (preBackgroundPush || oldPushHandlerOnly || noPushPayload) { 
      [PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions]; 
     } 
    } 

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000 
    if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) { 
     UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert | 
                 UIUserNotificationTypeBadge | 
                 UIUserNotificationTypeSound); 
     UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes 
                       categories:nil]; 
     [application registerUserNotificationSettings:settings]; 
     [application registerForRemoteNotifications]; 
    } else 
#endif 
    { 
     [application registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | 
                 UIRemoteNotificationTypeAlert | 
                 UIRemoteNotificationTypeSound)]; 
    } 



// self.window.rootViewController=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"emailStoryboard"]; 

    return YES; 
} 

/* 

/////////////////////////////////////////////////////////// 
// Uncomment this method if you are using Facebook 
/////////////////////////////////////////////////////////// 

- (BOOL)application:(UIApplication *)application 
      openURL:(NSURL *)url 
    sourceApplication:(NSString *)sourceApplication 
     annotation:(id)annotation { 
    return [PFFacebookUtils handleOpenURL:url]; 
} 

*/ 

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken { 
    [PFPush storeDeviceToken:newDeviceToken]; 
    [PFPush subscribeToChannelInBackground:@"" target:self selector:@selector(subscribeFinished:error:)]; 
} 

- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error { 
    if (error.code == 3010) { 
     NSLog(@"Push notifications are not supported in the iOS Simulator."); 
    } else { 
     // show some alert or otherwise handle the failure to register. 
     NSLog(@"application:didFailToRegisterForRemoteNotificationsWithError: %@", error); 
    } 
} 

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { 
    [PFPush handlePush:userInfo]; 

    if (application.applicationState == UIApplicationStateInactive) { 
     [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo]; 
    } 
} 

/////////////////////////////////////////////////////////// 
// Uncomment this method if you want to use Push Notifications with Background App Refresh 
/////////////////////////////////////////////////////////// 
/* 
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler { 
    if (application.applicationState == UIApplicationStateInactive) { 
     [PFAnalytics trackAppOpenedWithRemoteNotificationPayload:userInfo]; 
    } 
} 
*/ 

- (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:. 
    */ 
} 

#pragma mark -() 

- (void)subscribeFinished:(NSNumber *)result error:(NSError *)error { 
    if ([result boolValue]) { 
     NSLog(@"ParseStarterProject successfully subscribed to push notifications on the broadcast channel."); 
    } else { 
     NSLog(@"ParseStarterProject failed to subscribe to push notifications on the broadcast channel."); 
    } 
} 

@end 

답변

2

당신이 왼쪽에있는 파일 탐색기에서 프로젝트를 클릭하면?

enter image description here

또한

당신이 말한 (나는 생각한다), 스토리 보드이라고하지만 코드가 Main를 호출 한 다음 스토리 보드와 아무것도하지 않고 또는 확인되어, Main_iPhone 전화의 nil

당신 경우 대상에 기본 인터페이스를 설정하거나 viewControllerdidFinishLaunchingWithOptions 안에 인스턴스화하고이를 창의 rootViewController로 설정해야합니다. 예 :

self.window.rootViewController=[[UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil] instantiateInitialViewController]; 

둘 중 하나만 수행 할 필요는 없습니다.

+0

그래, 나에게 혼란 스럽다. 기본으로 더 나은 이름 인 Main_iPhone Storyboard 또는 Main Stoaryboard. – user4402918

관련 문제