English 中文(简体)
武库控制器根控制器背顿
原标题:back button at root controller of uinavigationcontroller

我有一架UINavigationController应用程序,有根基望控制器,每次我把视力控制器推向 st。 让我说,“B C D”是这里的根基控制器。 问题在于,当我看着控制人D,当我看上去时,他又回到A,但A又回到了 but子。 当我点击背后只是滑坡和消失的时候,为什么发生这种情况?

http://www.un.org。 我实际上把我的美国海军司令部归为一等,以便我能够把我的根基的话说成:

#import "CustomNavigationController.h"

@implementation CustomNavigationController

@synthesize fakeRootViewController;

//override to remove fake root controller
-(NSArray *)viewControllers {
    NSArray *viewControllers = [super viewControllers];     
if (viewControllers != nil && viewControllers.count > 0) {  
NSMutableArray *array = [NSMutableArray arrayWithArray:viewControllers];        
[array removeObjectAtIndex:0];  
    return array;   } 
    return viewControllers; }

//override so it pops to the perceived root
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated {
    //we use index 0 because we overrided “viewControllers”
    ((UIViewController *)[self.viewControllers objectAtIndex:0]).navigationItem.hidesBackButton = YES;
    return [self popToViewController:[self.viewControllers objectAtIndex:0] animated:animated]; }

//this is the new method that lets you set the perceived root, the previous one will be popped (released)
-(void)setRootViewController:(UIViewController *)rootViewController {
    rootViewController.navigationItem.hidesBackButton = YES;
    [self popToViewController:fakeRootViewController animated:NO];
    [self pushViewController:rootViewController animated:NO]; }

- (void)dealloc {
    self.fakeRootViewController = nil;
    [super dealloc]; }


-(id)initWithCoder:(NSCoder *)aDecoder{
    self = [super initWithCoder:aDecoder];
    if(self){
        UIViewController *fakeController = [[[UIViewController alloc] init] autorelease];
        self.fakeRootViewController = fakeController;
        NSMutableArray *array = [NSMutableArray arrayWithArray:[super viewControllers]];
        [array insertObject:fakeController atIndex:0];
        self.viewControllers = array;
    }
    return self; }

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn t have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren t in use. }

#pragma mark - View lifecycle

/* // Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView { }
*/

/* // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad]; }
*/

- (void)viewDidUnload {
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil; }

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait); }

@end

www.un.org/Depts/DGACM/index_spanish.htm MORE UPDATE:

因此,在我打下了根基的“Controller”号之后,我接着推倒了一位观点主计长,然后试图从这个观点中叫PpopToRootViewController。 然而,如果我在第二位之后再提出另一个观点,然后叫人ToRootViewController,那么,现在我可以看到,我们沉 back于根底。

问题回答

我也面临同样的问题。 因此,在您的根治里,派人离开BarButton 项目等于零。

self.navigationItem.leftBarButtonItem = nil;

如果您的根治者重新利用该方案的话。 然后需要检查——和;

BOOL needBackBarButton = (1 < [self.navigationController.viewControllers count]) ? YES : NO ; 
if (! needBackBarButton)
{
    self.navigationItem.leftBarButtonItem = nil;
}

其他控制人员

if (needBackBarButton)
{
          // Create custom navigationItem here.
}
else 
{
    self.navigationItem.leftBarButtonItem = nil;
}




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签