如果你使用pushViewController来推送UIImagePickerController
[self.navigationController pushViewController:pvc animated:YES];
Run Code Online (Sandbox Code Playgroud)
你会得到错误的
不支持推送导航控制器
正确的解决方案是使用presentModalViewController
[self presentModalViewController:pvc animated:YES];
Run Code Online (Sandbox Code Playgroud)
那么这个案子的深层原因是什么?UIViewController中隐藏了什么?
谢谢
uiimagepickercontroller pushviewcontroller presentmodalviewcontroller ios
更新:
我再次遇到了这个问题,并找到了另一种方法.如果呈现控制器未嵌入导航控制器中,则如果呈现的控制器不是全屏并且将变为黑色,则将隐藏它.方法setModalPresentationStyle:UIModalPresentationCurrentContext只能应用于导航控制器.因此,在UINavigationController中嵌入呈现控制器,将UIModalPresentationCurrentContext设置为它并呈现新的控制器 - 您将获得对话框控制器.
我正在呈现搜索控制器,它有tableView推送堆栈详细控制器.
详细的控制器可以显示带有消息的视图控制器,它由小UIView和半透明背景组成.
问题:当最后一个视图控制器出现时,它下面的所有视图控制器都变得隐藏,而控制器,呈现搜索控制器变得可见
我在做什么:
SearchViewController *viewController = [[SearchViewController alloc] initWithNibName:@"SearchViewController" bundle:nil];
viewController.data = dataArray;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
[self.navigationController setModalPresentationStyle:UIModalPresentationCurrentContext];
[self.navigationController presentViewController:navigationController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
比表推动详细视图:
DetailViewController *viewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
[viewController setHidesBottomBarWhenPushed:YES];
viewController.dataItem = [data objectAtIndex:(NSUInteger) [indexPath row]];
[self.navigationController pushViewController:viewController animated:YES];
Run Code Online (Sandbox Code Playgroud)
和详细的视图呈现消息框:
MessageController *controller = [[MessageController alloc] initWithNibName:@"MessageController" bundle:nil];
controller.message = message;
[self presentViewController:controller animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
当它被解雇时,其下的所有控制器都变得可见.
更新:
我想要的是以模态方式呈现一个具有uitableview的视图控制器.从此表中显示将能够显示消息框的详细视图.消息框必须是另一个视图控制器.当显示消息框时,所有前两个控制器都会消失.这就是问题所在.
iphone objective-c uiviewcontroller presentmodalviewcontroller ios
当我提出我UIViewController同modalPresentationStyle父的UINavigationController设置UIModalPresentationCurrentContext,在UIViewController不滑动,没有使用过渡.
这是我的代码:
UIViewController *viewController = [[UIViewController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
navController.navigationBarHidden = YES;
self.navigationController.modalPresentationStyle = UIModalPresentationCurrentContext;
[self presentViewController:navController animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
当我没有设置modalPresenttionStyle,一切正常.但我需要这种风格,因为我希望UIViewController礼物是叠加的.
BTW:当ViewController被解雇时,动画效果很好.
我正在展示带动画的模型视图.默认情况下,它来自自下而上.如何让动画从左到右?我知道我可以使用导航控制器.但实际上,呈现视图不需要导航栏,并且模态呈现的视图也不需要导航栏.我仍然希望从左到右过渡.
modal-dialog modalviewcontroller presentmodalviewcontroller ios
您好我正在使用工具栏上的一个标签栏按钮,此按钮将显示带有表格视图的下一个视图,这是我的代码
[self presentModalViewController:self.navigationController
animated:YES];
Run Code Online (Sandbox Code Playgroud)
我的问题是,当我单击此选项卡栏按钮时,它将显示带有tableview的下一个视图,但不显示导航栏.因为这个我无法在tableView中执行删除操作.
如何解决这个问题?
我们有2个控制器:MainVC和ProfileVC.从MainVC我们profileButton按下ProfileDC (导航栏上的左侧项目).
在Profile VC中,导航栏上有2个按钮:返回main(leftItem)并打开alertView(rightItem).
所以有简单的KIF测试(导航栏上只有永久的左右点击):
- (void)testProfileButtons
{
[tester waitForAnimationsToFinishWithTimeout:0.3];
while (true)
{
[tester tapScreenAtPoint:CGPointMake(20, 20)];
[tester waitForTimeInterval:0.1];
[tester tapScreenAtPoint:CGPointMake(380, 20)];
[tester waitForTimeInterval:0.1];
[tester tapScreenAtPoint:CGPointMake(20, 20)];
[tester waitForTimeInterval:0.1];
}
}
Run Code Online (Sandbox Code Playgroud)
它崩溃了应用程序错误:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <UINavigationController: 0x7fe862ef82d0>.'
*** First throw call stack:
(
0 CoreFoundation 0x0000000110944c65 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x00000001105dabb7 objc_exception_throw + 45
2 UIKit 0x000000010f44b80d -[UIViewController _presentViewController:withAnimationController:completion:] + 3238
3 UIKit 0x000000010f44d6c1 …Run Code Online (Sandbox Code Playgroud) 我知道有三种方法可以在iOS中更改视图
1.
[self addChildViewController:thirdViewController];
[contentView addSubview:thirdViewController.view];
Run Code Online (Sandbox Code Playgroud)
2.
First * sVC = [[First alloc] initWithNibName:@"First" bundle:[NSBundle mainBundle]];
[self presentModalViewController:sVC animated:YES];
Run Code Online (Sandbox Code Playgroud)
3.
MyViewController *sampleViewController = [[[MyViewController alloc]initWithXXX] autorelease];
[self.navigationController pushViewController: sampleViewController animated:true];
Run Code Online (Sandbox Code Playgroud)
pushViewController需要导航控制器,我理解.但是,何时使用addChildViewController和presentModalViewController?
view addchild pushviewcontroller presentmodalviewcontroller ios
我有代表工作,因为数据正从模态传递到呈现视图控制器.但是呈现视图控制器没有显示它从模态接收的数据.我查看了其他帖子,他们说要使用委托/协议方法,但不解释如何/为什么呈现VC刷新.我假设我的委托设置不正确.否则,刷新数据的方法是什么?我已经检查过了,并且没有调用viewWillAppear和viewDidAppear.
SCCustomerDetailVC.h(呈现VC)
#import "SCCustomersVC.h"
@interface SCCustomerDetailVC : UIViewController <SCCustomersVCDelegate>
@property (atomic, strong) SCCustomer *customer;
@property (strong, nonatomic) IBOutlet UIButton *changeCustomerButton;
- (IBAction)changeCustomerButtonPress:(UIButton *)sender;
@end
Run Code Online (Sandbox Code Playgroud)
SCCustomerDetailVC.m(呈现VC)
- (IBAction)changeCustomerButtonPress:(UIButton *)sender
{
UINavigationController *customersNC = [self.storyboard instantiateViewControllerWithIdentifier:@"customersNC"];
SCCustomersVC *customersVC = (SCCustomersVC *)customersNC.topViewController;
customersVC.delegate = self;
[self presentViewController:customersNC animated:YES completion:nil];
}
//Protocol methods
- (void)passCustomer:(SCCustomer *)customer
{
self.customer = customer;
//At this point, self.customer has the correct reference
[self dismissViewControllerAnimated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
SCCustomersVC.h(模态VC)
#import "SCCustomersVCDelegate.h"
@class SCCustomerDetailVC;
@interface SCCustomersVC : UIViewController <UITableViewDelegate, UITableViewDataSource, UISearchBarDelegate> …Run Code Online (Sandbox Code Playgroud) delegates protocols objective-c presentmodalviewcontroller ios
我已经尝试了很多组合来做这个从app委托,呈现视图控制器viewDidLoad,有和没有延迟,有和没有动画.
但是用户可以暂时看到呈现视图控制器,或者模式没有呈现.
怎么能实现这一目标?
modal-dialog objective-c launch presentmodalviewcontroller ios
我有标签栏,在视图"A"和"A"我有导航控制器.所以我的导航控制器里面的"A"我叫了
[self presentModalViewController:modalView animated:YES]
Run Code Online (Sandbox Code Playgroud)
但modalView显示在标签栏下.如何在标签栏上方显示它?
objective-c uitabbarcontroller presentmodalviewcontroller ios
presentmodalviewcontroller ×10
ios ×9
objective-c ×6
iphone ×3
modal-dialog ×2
addchild ×1
delegates ×1
launch ×1
protocols ×1
view ×1
xcode ×1