iOS-按下“后退”按钮时,导航标题来自左侧

iOS-按下“后退”按钮时,导航标题来自左侧,ios,objective-c,uiviewcontroller,Ios,Objective C,Uiviewcontroller,在我的应用程序中,当我访问某些视图控制器并触摸导航栏中的“后退”按钮时,生成的视图控制器的导航标题看起来来自左上角,看起来很难看 下面显示了这样一个实例的图片 我已按程序设置了标题 有人能告诉我为什么会发生这种情况,以及我如何解决它吗?提前谢谢 这是我的密码: 视图控制器B - (void)viewDidLoad { [super viewDidLoad]; UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake

在我的应用程序中,当我访问某些视图控制器并触摸导航栏中的“后退”按钮时,生成的视图控制器的导航标题看起来来自左上角,看起来很难看

下面显示了这样一个实例的图片

我已按程序设置了标题

有人能告诉我为什么会发生这种情况,以及我如何解决它吗?提前谢谢

这是我的密码:

视图控制器B

- (void)viewDidLoad
{
    [super viewDidLoad];

    UILabel * label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,120,45)] ;
    label.textColor = COLOR_TEXT_NAVIGATION_BAR_COLOR;
    label.backgroundColor = [UIColor clearColor];
    label.font = FONT_NAVIGATION_TITLE_BAR;
    label.text = [NSString stringWithFormat:PAGE_TITLE_ADD_SERVICE_PROVIDER];
    self.navigationItem.titleView = label;
    [label sizeToFit];


    UIButton *homeButton = [[UIButton alloc] initWithFrame:CGRectMake(20, 20, 20, 20)];
    [homeButton setImage:[UIImage imageNamed:IMG_HOME_MENU_BUTTON] forState:UIControlStateNormal];
    [homeButton addTarget:self action:@selector(homeMenuAction) forControlEvents:UIControlEventTouchUpInside];
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:homeButton];


    accNumTextFiled.delegate=self;

    nameTextFiled.text = addPayee.providerName;
    payLimitTextFiled.text = [NSString stringWithFormat:@"%9.2f", addPayee.paymentLimit];//[NSString stringWithFormat:@"%f",addPayee.paymentLimit];
    descTextFiled.text = addPayee.description;
    catTextFiled.text = addPayee.maincategory;
    subCatTextFiled.text = addPayee.subcategory;

    accNumTextFiled.text = addPayee.paymentAccountNumber;

    [accNumTextFiled setKeyboardType:UIKeyboardTypeNumberPad];

    [self labelCss];

    scrollView.contentSize=CGSizeMake(320,450);
}
视图控制器A

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.view.backgroundColor = COLOR_BG_INNER_PAGE_COLOR;


    NSArray *mappingObjArray1  = @[@"providerName",@"description",@"paymentLimit",@"providerCode",@"maincategory",@"subcategory"];

    NSDictionary *queryParams = @{};


    commonRestDataMapping = nil;
    commonRestDataMapping = [[CommonRestDataMapping alloc] init];
    commonRestDataMapping.restDataMappingDelegate = self;
    commonRestDataMapping.servicePath = REST_WEB_SERVICE_ADD_PAYEE_LIST;
    commonRestDataMapping.mappingObjArray = mappingObjArray1;
    commonRestDataMapping.mappingClassString = @"AddPayee";
    commonRestDataMapping.mappingKeyPath = @"data";
    commonRestDataMapping.mappingQueryParams = queryParams;


    [commonRestDataMapping configureRestKit];
    [commonRestDataMapping loadDataArray];


    if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
        self.edgesForExtendedLayout = UIRectEdgeNone;

}


-(void)viewWillAppear:(BOOL)animated{

    [super viewWillAppear:animated];
    [super createNavigationBar:USER_ACCOUNT_PAGE];
    [super setNavihationTitle:PAGE_TITLE_ADD_PAYEE];
    [self.navigationController setNavigationBarHidden:NO animated:animated];

}
AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

    //WEB service data initilization
    [[WebServiceUrl getSharedInstance] dataiInitialize];

    [GMSServices provideAPIKey:@"AIzaSyCBfhnMtcmdhJaaqff72PlvJIjBTZpfSu4"];

    NSString* docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject];
    NSString* dbPath = [docPath stringByAppendingPathComponent:@"datadb.sqlite"];
    NSFileManager *fm = [NSFileManager defaultManager];

    // Check if the database is existed.
    if(![fm fileExistsAtPath:dbPath])
    {
        // If database is not existed, copy from the database template in the bundle
        NSString* dbTemplatePath = [[NSBundle mainBundle] pathForResource:@"datadb" ofType:@"sqlite"];
        NSError* error = nil;
        [fm copyItemAtPath:dbTemplatePath toPath:dbPath error:&error];
        if(error){
            NSLog(@"can't copy db.");
        } else{
            NSLog(@" copy db.");
        }
    } else {
        NSLog(@"  db exsists");
    }


    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0) {
        UIView *addStatusBar = [[UIView alloc] init];
        addStatusBar.frame = CGRectMake(0, 0, 1024, 20);
        addStatusBar.backgroundColor = [UIColor blackColor]; //change this to match your navigation bar

        [self.window.rootViewController.view addSubview:addStatusBar];
    }



    homeViewController = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:nil];
    UINavigationController *myNav1=[[UINavigationController alloc] initWithRootViewController:homeViewController];


    UIImage *navBackgroundImg = [UIImage imageNamed:@"aa1.png"];

    [myNav1.navigationBar setBackgroundImage:navBackgroundImg forBarMetrics:UIBarMetricsDefault];//iOS 5 only

    // Override point for customization after application launch.
    self.viewController = myNav1;
    self.window.rootViewController = self.viewController;
    [self.window makeKeyAndVisible];



    return YES;
}

- (void)transitionToViewController:(UIViewController *)viewController
                    withTransition:(UIViewAnimationOptions)transition
{
    [UIView transitionFromView:self.window.rootViewController.view
                        toView:viewController.view
                      duration:0.35f
                       options:transition
                    completion:^(BOOL finished){
                        self.window.rootViewController = viewController;
                    }];
}

也许你可以发布一些可能适用的代码?嗨@Mike,我添加了一些代码。请尝试不带动画的popViewControllerAnimated。[self.navigationController PopViewControllerInitiated:否]@V.J.试过了,没用/你能为[super createNavigationBar:USER_ACCOUNT_PAGE]输入代码吗;[超级设置导航标题:页面标题添加收款人];[self.navigationController setNavigationBarHidden:无动画:动画];