GVKun编程网logo

如果模态 ViewController 演示样式为 UIModalPresentationFormSheet,iPad 键盘将不会关闭

18

本文将介绍如果模态ViewController演示样式为UIModalPresentationFormSheet,iPad键盘将不会关闭的详细情况,。我们将通过案例分析、数据研究等多种方式,帮助您更全

本文将介绍如果模态 ViewController 演示样式为 UIModalPresentationFormSheet,iPad 键盘将不会关闭的详细情况,。我们将通过案例分析、数据研究等多种方式,帮助您更全面地了解这个主题,同时也将涉及一些关于iOS present AlertController时崩溃 'Application tried to present modally an active controller .'、iOS presentViewController 与 pushViewController 中的注意点、iOS presentViewController 推出半屏幕透明 UIViewController、ios – addChildViewController和presentModelViewController之间有什么区别?的知识。

本文目录一览:

如果模态 ViewController 演示样式为 UIModalPresentationFormSheet,iPad 键盘将不会关闭

如果模态 ViewController 演示样式为 UIModalPresentationFormSheet,iPad 键盘将不会关闭

笔记:

从 iOS 4.3 开始,请参阅已接受的答案(不是投票最多的答案)以获取解决方案。

这个 问题 是关于在 iPad 键盘中发现的一种行为,如果在带有导航控制器的模式对话框中显示它,它会拒绝被关闭。

基本上,如果我向导航控制器显示以下行:

navigationController.modalPresentationStyle = UIModalPresentationFormSheet;

键盘拒绝被解雇。如果我注释掉这一行,键盘就会消失。

我有两个文本字段,用户名和密码;用户名有一个下一步按钮,密码有一个完成按钮。如果我在模态导航控制器中显示它,键盘不会消失。

作品

broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];[self.view addSubview:b.view];

不工作

broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:b];navigationController.modalPresentationStyle = UIModalPresentationFormSheet;navigationController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;[self presentModalViewController:navigationController animated:YES];[navigationController release];[b release];

如果我删除导航控制器部分并将“b”单独呈现为模态视图控制器,它就可以工作。导航控制器有问题吗?

作品

broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];b.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;[self presentModalViewController:b animated:YES];[b release];

作品

broken *b = [[broken alloc] initWithNibName:@"broken" bundle:nil];UINavigationController *navigationController =     [[UINavigationController alloc]         initWithRootViewController:b];[self presentModalViewController:navigationController animated:YES];[navigationController release];[b release];

答案1

小编典典

在模态显示的视图控制器中,只需覆盖disablesAutomaticKeyboardDismissal返回NO

- (BOOL)disablesAutomaticKeyboardDismissal {    return NO;}

iOS present AlertController时崩溃 'Application tried to present modally an active controller <HKConnectViewController: 0x1050158e0>.'

iOS present AlertController时崩溃 'Application tried to present modally an active controller .'

*** Terminating app due to uncaught exception ‘NSinvalidargumentexception‘,reason: ‘Application tried to present modally an active controller <HKConnectViewController: 0x1050158e0>.‘

 

分析:

很有可能是你的触发事件中,触发了多次。也就是说:需要不止一次present。

解决办法:

加入单例,保证只执行一次

    static dispatch_once_t oncetoken;
    dispatch_once(&oncetoken,^{
        [self presentViewController:self.bluetoothCloseAlertC animated:YES completion:nil];
    });

iOS presentViewController 与 pushViewController 中的注意点

iOS presentViewController 与 pushViewController 中的注意点

从数据到大模型应用,11 月 25 日,杭州源创会,共享开发小技巧

要做 push,前提要存在 navigationController。 present 进来的页面如果有 push 操作,该页面必须带有 NavigationController。

iOS presentViewController 推出半屏幕透明 UIViewController

iOS presentViewController 推出半屏幕透明 UIViewController

iOS presentViewController 推出半屏幕透明 UIViewController

不废话,直接上代码

1.父页面打开方式

/**
 *  页面打开配置
 *
 *  @param sender <#sender description#>
 */
- (IBAction)shwoViewAction:(id)sender {
    
    TTViewController *tView = [[TTViewController alloc] init];
    //设置模式展示风格
    [tView setModalPresentationStyle:UIModalPresentationOverCurrentContext];
    //必要配置
    self.modalPresentationStyle = UIModalPresentationCurrentContext;
    self.providesPresentationContextTransitionStyle = YES;
    self.definesPresentationContext = YES;
    [self presentViewController:tView animated:YES completion:nil];
}

 2.子页面重写viewWillLayoutSubviews,设置位置宽高

#define DeviceHeight [[UIScreen mainScreen] bounds].size.height
#define DeviceWidth [[UIScreen mainScreen] bounds].size.width

/**
 *  设置位置宽高
 */
- (void)viewWillLayoutSubviews {
  
    self.view.frame = CGRectMake(self.view.frame.origin.x, DeviceHeight / 2, DeviceWidth, DeviceHeight / 2);
    //self.view.backgroundColor = [UIColor clearColor];
    //self.view.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.868f];
}

 打完收工。

ios – addChildViewController和presentModelViewController之间有什么区别?

ios – addChildViewController和presentModelViewController之间有什么区别?

我知道有三种方法来改变iOS中的视图

1.

[self addChildViewController:thirdViewController]; 
[contentView addSubview:thirdViewController.view];

2.

First * sVC = [[First alloc] initWithNibName:@"First" bundle:[NSBundle mainBundle]]; 
[self presentModalViewController:sVC animated:YES];

3.

MyViewController *sampleViewController = [[[MyViewController alloc]initWithXXX] autorelease];       
[self.navigationController pushViewController: sampleViewController animated:true];

pushViewController需要导航控制器,我明白了.但是,何时使用addChildViewController和presentModalViewController?

解决方法

这是四个完全不同的实现

> addChildViewController在iOS5中用于执行viewController控制,这将使您能够轻松创建自己的NavigationCotrollers或TabController,它仅在iOS5中可用> addSubview是最低级的三个,这只会添加一个视图到另一个视图,作为一个孩子> presentModalViewController用于在屏幕上以模态方式呈现viewController,因此覆盖旧的视图控件> pushViewController在UINavigationController中使用,将一个新的ViewController推送到viewcontrollers堆栈,

关于如果模态 ViewController 演示样式为 UIModalPresentationFormSheet,iPad 键盘将不会关闭的问题我们已经讲解完毕,感谢您的阅读,如果还想了解更多关于iOS present AlertController时崩溃 'Application tried to present modally an active controller .'、iOS presentViewController 与 pushViewController 中的注意点、iOS presentViewController 推出半屏幕透明 UIViewController、ios – addChildViewController和presentModelViewController之间有什么区别?等相关内容,可以在本站寻找。

本文标签: