2013-04-25 3 views
1

알림에서 앱을 열 때 특정보기를 열려면 코드를 내 didFinishLaunchingWithOptions 메서드에 추가했습니다. 나는 그보기를 위해 네비게이션 바에 "dismiss"버튼을 추가했다. 모달보기를 닫은 후 사용자가 홈 화면으로 이동하도록 단추를 가져 오려고합니다. 사용자가 버튼을 탭하면 앱이 다운됩니다. 여기있는 사람 중에 아이디어가 있습니까?모달 뷰 컨트롤러 닫기

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    // This prevents the UA Library from registering with UIApplcation by default when 
    // registerForRemoteNotifications is called. This will allow you to prompt your 
    // users at a later time. This gives your app the opportunity to explain the benefits 
    // of push or allows users to turn it on explicitly in a settings screen. 
    // If you just want everyone to immediately be prompted for push, you can 
    // leave this line out. 
    // [UAPush setDefaultPushEnabledValue:NO]; 

    //Create Airship options dictionary and add the required UIApplication launchOptions 
    NSMutableDictionary *takeOffOptions = [NSMutableDictionary dictionary]; 
    [takeOffOptions setValue:launchOptions forKey:UAirshipTakeOffOptionsLaunchOptionsKey]; 

    // Call takeOff (which creates the UAirship singleton), passing in the launch options so the 
    // library can properly record when the app is launched from a push notification. This call is 
    // required. 
    // 
    // Populate AirshipConfig.plist with your app's info from https://go.urbanairship.com 
    [UAirship takeOff:takeOffOptions]; 

    // Set the icon badge to zero on startup (optional) 
    [[UAPush shared] resetBadge]; 

    // Register for remote notfications with the UA Library. This call is required. 
    [[UAPush shared] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge | 
                 UIRemoteNotificationTypeSound | 
                 UIRemoteNotificationTypeAlert)]; 

    // Handle any incoming incoming push notifications. 
    // This will invoke `handleBackgroundNotification` on your UAPushNotificationDelegate. 
    [[UAPush shared] handleNotification:[launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey] 
         applicationState:application.applicationState]; 

    // self.tabBarController = [[UITabBarController alloc] initWithNibName:@"KFBViewController" bundle:nil]; 
    KFBViewController *rootView = [[KFBViewController alloc] initWithNibName:@"KFBViewController" bundle:nil]; 
    KFBNavControllerViewController *navController = [[KFBNavControllerViewController alloc] initWithRootViewController:rootView]; 
    navController.delegate = rootView; 
    UIViewController *aboutUs = [[AboutUs alloc] initWithNibName:@"AboutUs" bundle:nil]; 
    KFBNavControllerViewController *navController1 = [[KFBNavControllerViewController alloc] initWithRootViewController:aboutUs]; 

    UIViewController *contactUs = [[ContactUs alloc] initWithNibName:@"ContactUs" bundle:nil]; 
    KFBNavControllerViewController *navController2 = [[KFBNavControllerViewController alloc] initWithRootViewController:contactUs]; 

    UIViewController *kyfb = [[KYFB alloc] initWithNibName:@"KYFB" bundle:nil]; 
    KFBNavControllerViewController *navController3 = [[KFBNavControllerViewController alloc] initWithRootViewController:kyfb]; 

    // UIViewController *rsfm = [[RSFM alloc] initWithNibName:@"RSFM" bundle:nil]; 
    // KFBNavControllerViewController *navController4 = [[KFBNavControllerViewController alloc] initWithRootViewController:rsfm]; 

    // UIViewController *li = [[LegislatorInfo alloc] initWithNibName:@"LegislatorInfo" bundle:nil]; 
    // KFBNavControllerViewController *navController5 = [[KFBNavControllerViewController alloc] initWithRootViewController:li]; 

    // UIViewController *events = [[Events alloc] initWithNibName:@"Events" bundle:nil]; 
    // KFBNavControllerViewController *navController6 = [[KFBNavControllerViewController alloc] initWithRootViewController:events]; 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 

    //self.viewController = [[KFBViewController alloc] initWithNibName:@"KFBViewController" bundle:nil]; 
    //self.window.rootViewController = self.viewController; 
    self.tabBarController = [[KFBTabBarViewController alloc] init]; 
    self.tabBarController.viewControllers = @[navController, navController1, navController2, navController3]; 
    // self.tabBarController.customizableViewControllers = nil; 

    self.window.rootViewController = self.tabBarController; 
    self.window.backgroundColor = [UIColor whiteColor]; 
    [self.window makeKeyAndVisible]; 

    // If application is launched due to notification,present another view controller. 
    UILocalNotification *notification = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey]; 

    if (notification) 
    { 
     ActionAlertsViewController *actionAlerts = [[ActionAlertsViewController alloc] initWithStyle:UITableViewStylePlain]; 
     WebViewController *wvc = [[WebViewController alloc]init]; 
     [actionAlerts setWebViewController:wvc]; 
     KFBNavControllerViewController *navController7 = [[KFBNavControllerViewController alloc] initWithRootViewController:actionAlerts]; 
     actionAlerts.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc ] initWithTitle:@"Dismiss" style:UIBarButtonItemStyleBordered target:self action:@selector(dismiss:)]; 
     [self.window.rootViewController presentViewController:navController7 animated:NO completion:nil]; 
    } 

    return YES; 
} 



- (IBAction)dismiss 
{ 
    [self.window.rootViewController dismissViewControllerAnimated:NO completion:nil]; 

} 

답변

2

작동합니다. 이 시도 :

[self.window.rootViewController dismissViewControllerAnimated:NO completion:nil]; 

편집 후 :

내가 지금 문제를 참조하십시오 - 당신의 바 버튼 항목의 액션 메소드는 해고입니다 : (콜론)을 더 콜론 기각 구현하는 반면. 그들은 동일해야합니다.

+0

사실 내가 원래 가지고 있었고 또한 응용 프로그램을 충돌합니다. – raginggoat

+0

@ user2029585, 오류 메시지가 나타 납니까? – rdelmar

+0

오류 메시지가 없습니다. – raginggoat

1

p.e. 터치 업 내부를 통해있는 UIButton 당신은 self.tabBarController입니다 윈도우의 루트 뷰 컨트롤러에서이 컨트롤러를 제시하지만, 네비게이션 컨트롤러를 기각하고

[self dismissModalViewControllerAnimated:YES]; 
관련 문제