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)viewWillAppearBOOL)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
我该怎么做!
Best Answer-推荐答案 strong>
尝试在 MoreFunctionViewController 中设置标题:
MyShakeViewController *myshakeView = [[MyShakeViewController alloc] init];
myShakeView.title = @"TestTitle";
[self.navigationController pushViewController:myshakeView animated:YES];
[myshakeView release];
至于 为什么,我不确定,我只使用 initWithNibName (所以标题是从 nib 加载的)和/或在导航项中使用自定义标题 View (所以我用我自己的 View 替换标题 View )所以我没有使用您的特定设置。
关于objective-c - 关于 self.navigationController pushViewController (IOS),我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/7657353/
|