开发者

about self.navigationController pushViewController (IOS)

MoreFunctionViewController.h code like this:

      #import <UIKit/UIKit.h>


      @interface MoreFunctionViewController : UIViewController <UITableViewDelegate,UITableViewDataSource>{

            UITableView *moreTable;

      }
      @property (nonatomic, retain) UITableView *moreTable;


      @end

and MoreFunctionViewController.m code like this:

      #import "MoreFunctionViewController.h"
      #import "CustomNavigationBar.h"
      #import "MyShakeViewController.h"

      @implementation MoreFunctionViewController

      @synthesize moreTable;

      - (void)viewDidLoad {
        [super viewDidLoad];
        self.title = @"More";

        CGRect tableFrame = self.view.frame;
        tableFrame.origin.y -= 20; 
        moreTable = [[UITableView alloc] initWithFrame:tableFrame style:UITableViewStyleGrouped];
        moreTable.delegate = self;
        moreTable.dataSource = self;
        moreTable.backgroundColor = [UIColor clearColor];
        [self.view addSubview:moreTable];
      }

      - (void)viewWillAppear:(BOOL)animated
      {
             [super viewWillAppear:animated];

         [self.navigationController.navigationBar setBackgroundImage:nil];
         [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"twoNavbar.png"]];
     }


     ..................
     ..................

     - (void)table开发者_如何学GoView: (UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath 
     {
       if (indexPath.section == 0) {
          if (indexPath.row == 0) {
        NSLog(@"ddd");
        MyShakeViewController *myshakeView = [[MyShakeViewController alloc] init];
        [self.navigationController pushViewController:myshakeView animated:YES];
        [myshakeView release];

    }

       }

    }

the MyShakeViewController -(void) viewDidLoad method like this:

   -(void) viewDidLoad{
       self.title = @"TestTitle"; 
   }

but cant see the Title. if I change the

[self.navigationController pushViewController:myshakeView animated:YES];

To

[self.navigationController pushViewController:myshakeView animated:NO];

I can see the title , this why?

but I need the animated YES

How can I do it!


Try setting the title from within your MoreFunctionViewController:

MyShakeViewController *myshakeView = [[MyShakeViewController alloc] init];
myShakeView.title = @"TestTitle";
[self.navigationController pushViewController:myshakeView animated:YES];
[myshakeView release];

As for why, I'm not sure, I've only ever created view controllers using initWithNibName (so the title is loaded from the nib) and / or with custom title views in the navigation item (so I replace the title view with my own view) so I haven't used your particular setup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜