不在 modalView 上显示 UINavigationController

发布于 2025-01-04 02:39:06 字数 578 浏览 1 评论 0原文

我问

[self presentModalViewController:searchRegionController animated:YES]; 

之后我尝试添加 NavigationController

   self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(next:)] autorelease];
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelAdd:)] autorelease]
    self.navigationItem.titleView =  someView;

I'm asking

[self presentModalViewController:searchRegionController animated:YES]; 

after that I try to add NavigationController by

   self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(next:)] autorelease];
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelAdd:)] autorelease]
    self.navigationItem.titleView =  someView;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

妖妓 2025-01-11 02:39:06

所以就这样做
在 searchRegionController 类中

-(void)viewDidLoad
{
     UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[self.view addSubview:naviBarObj];
UIBarButtonItem *rightBarButtonItem =[[[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(next:)] autorelease];

UIBarButtonItem *leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelAdd:)] autorelease];

UINavigationItem *navigItem = [[UINavigationItem alloc] initWithTitle:@"Navigation Title"];
navigItem.rightBarButtonItem = rightBarButtonItem;
navigItem.leftBarButtonItem = leftBarButtonItem;
naviBarObj.items = [NSArray arrayWithObjects: navigItem,nil];
}

希望这有帮助。

so do like this
in the searchRegionController class

-(void)viewDidLoad
{
     UINavigationBar *naviBarObj = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
[self.view addSubview:naviBarObj];
UIBarButtonItem *rightBarButtonItem =[[[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(next:)] autorelease];

UIBarButtonItem *leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelAdd:)] autorelease];

UINavigationItem *navigItem = [[UINavigationItem alloc] initWithTitle:@"Navigation Title"];
navigItem.rightBarButtonItem = rightBarButtonItem;
navigItem.leftBarButtonItem = leftBarButtonItem;
naviBarObj.items = [NSArray arrayWithObjects: navigItem,nil];
}

hope this helps.

简美 2025-01-11 02:39:06

试试这个:

-(void)someAction
{
ViewController *object = [ViewController]alloc]initWithNibName:@"NibName" bundle:[NSBundle mainBundle];

UINavigationController *navController = [UINavigationCOntroller]alloc]initWithRootViewController:object];

[self presentModalViewController:navController animated:YES];

[object release];
[navController release];
}

在 ViewController 的 viewDidLoad 中执行以下操作:

 self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(next:)] autorelease];
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelAdd:)] autorelease]
    self.navigationItem.titleView =  someView;

Try this:

-(void)someAction
{
ViewController *object = [ViewController]alloc]initWithNibName:@"NibName" bundle:[NSBundle mainBundle];

UINavigationController *navController = [UINavigationCOntroller]alloc]initWithRootViewController:object];

[self presentModalViewController:navController animated:YES];

[object release];
[navController release];
}

And in the viewDidLoad of ViewController do :

 self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Add" style:UIBarButtonItemStyleBordered target:self action:@selector(next:)] autorelease];
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelAdd:)] autorelease]
    self.navigationItem.titleView =  someView;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文