MoreFunctionViewController.h
代码:
#import <UIKit/UIKit.h>
@interface MoreFunctionViewController : UIViewController <UITableViewDelegate,UITableViewDataSource>{
UITableView *moreTable;
}
@property (nonatomic, retain) UITableView *moreTable;
@end
和MoreFunctionViewController.m
代码如下:
#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)tableView: (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];
}
}
}
MyShakeViewController -(void) viewDidLoad
方法如下:
-(void) viewDidLoad{
self.title = @"TestTitle";
}
但是看不到标题。 如果我改变了
[self.navigationController pushViewController:myshakeView animated:YES];
要
[self.navigationController pushViewController:myshakeView animated:NO];
我可以看到title
,这是为什么?
但我需要动画YES
我该怎么做!
答案 0 :(得分:4)
尝试在MoreFunctionViewController
:
MyShakeViewController *myshakeView = [[MyShakeViewController alloc] init];
myShakeView.title = @"TestTitle";
[self.navigationController pushViewController:myshakeView animated:YES];
[myshakeView release];
至于为什么,我不确定,我只使用initWithNibName
创建了视图控制器(所以标题是从nib加载的)和/或自定义标题导航项中的视图(所以我用自己的视图替换标题视图)所以我没有使用您的特定设置。