Как удалить UINavigationViewController - PullRequest
1 голос
/ 15 сентября 2011

Я создал один навигационный контроллер в name_of_my_appAppDelegate.h ... После использования я хочу удалить его из суперпредставления ... в моем name_of_my_RootViewController я хочу вызвать его и удалить.

Как вызвать его?

В NewsPadViewController как удалить NavigationController после его использования?

#import <UIKit/UIKit.h>

@class NewsPadViewController;

@interface NewsPadAppDelegate : NSObject <UIApplicationDelegate>{
    UIWindow *window;
    UINavigationController *navigationController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@end

и это реализация

#import "NewsPadAppDelegate.h"
#import "NewsPadViewController.h"


@implementation NewsPadAppDelegate

@synthesize window;
@synthesize navigationController;


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    [window addSubview:navigationController.view];
    [window makeKeyAndVisible];
    return YES;
}

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

- (void)dealloc
{
    [navigationController release];
    [window release];
    [super dealloc];
}

@end

Ответы [ 3 ]

1 голос
/ 15 сентября 2011

Проверьте это: Справочник по классам UINavigationController .

Вы, вероятно, хотите что-то вроде этого:

[name_of_my_RootViewController popToRootViewControllerAnimated:YES];

Или:

[name_of_my_RootViewController.view removeFromSuperview];

Или:

for (UIView *v in self.view.subviews) {
    if ([v isEqual:myView]) {
        [myView removeFromSuperview];
    }
}

Или:

[((NewsPadAppDelegate *)[[UIApplication sharedApplication] delegate]).window.rootViewController.view removeFromSuperview];
1 голос
/ 15 сентября 2011

Звучит так, как будто вы должны представлять UINavigationController модально во-первых.Установите обычный UIViewController с именем rootViewController и сделайте его видимым вместо контроллера навигации, затем вызовите:

[rootViewController presentModalViewController:navigationController animated:YES];

. Когда вы закончите, нажмите кнопку на контроллере навигации, котораязвонки:

[self dismissModalViewControllerAnimated:YES];

И вы вернетесь на равнину UIViewController, где сможете показать остальную часть вашего приложения.

1 голос
/ 15 сентября 2011

Чтобы удалить контроллер вида, вы удалите его вид, например так:

[name_of_my_RootViewController.view removeFromSuperview];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...