Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 导航控制器完成按钮未显示_Iphone - Fatal编程技术网

Iphone 导航控制器完成按钮未显示

Iphone 导航控制器完成按钮未显示,iphone,Iphone,当我按下mainviewcontroller上的“信息”按钮时,它会以模式显示导航栏和uitextview,但不会显示“完成”按钮 - (void) modalViewAction:(id)sender self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease]; [self.view setFrame:CGRectMake(0, 0, self.view.f

当我按下mainviewcontroller上的“信息”按钮时,它会以模式显示导航栏和uitextview,但不会显示“完成”按钮

    - (void) modalViewAction:(id)sender     

 self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];

[self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];

 _viewController = [[ModalViewController alloc] init];

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_viewController];

 navigationController.navigationBar.tintColor = [UIColor brownColor];

self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(Done:)] autorelease];

[self.navigationController presentModalViewController:self.viewController animated:YES];

[navigationController release];
任何人都知道为什么navigationcontroller中缺少“完成”按钮


感谢您的帮助。

您可以通过以下方式进行演示:

[self.navigationController presentModalViewController:self.viewController animated:YES];
您需要将其推送到导航堆栈上:

[self.navigationController pushViewControler:self.viewController animated:YES];
现在导航控制器将为您处理“后退”按钮。

您必须:

  • 将视图控制器推到导航控制器上(如Hubert所示 解释),或
  • 创建新的UINavigationController并设置 viewController作为其根viewController UINavigationController,然后您可以执行以下操作:
  • [自导航控制器] presentModalViewController:newNavigationController动画:是]


    我补充说:

    [_viewController.navigationItem setLeftBarButtonItem:button animated:YES];
    
    导航控制器上显示以下代码和“立即完成”按钮

     - (void) modalViewAction:(id)sender
    
    {
    self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease]; 
    
    [self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    
     _viewController = [[ModalViewController alloc] init];
    
    UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:_viewController];
    
    UIBarButtonItem * button = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:    UIBarButtonSystemItemDone target:self action:@selector(dismissView:)] autorelease];
    
    [_viewController.navigationItem setLeftBarButtonItem:button animated:YES];
    
    navigationController.navigationBar.tintColor = [UIColor brownColor];
    
    [self.navigationController presentModalViewController:self.viewController animated:YES];
    
    [self.view addSubview:navigationController.view];
    
    [navigationController release];
    
    }
    
    所以我的问题解决了


    谢谢你的帮助

    如果我是以模态的方式演示的话。没有其他方法显示“完成”按钮。原因是我想在看到“完成”按钮后使用dismissmodalview。这就是为什么我不能使用PushView控制器的原因。我之前尝试使用PushView控制器,但无法使用PoptorootViewController来解除视图。我不确定您想要什么。如果你有一个后退按钮,你还需要手动弹出它吗?如果是,只需使用:[self.navigationController popViewControllerAnimated:YES];就像用户按下后退按钮一样。