iPad - 在UIModalPresentationFormSheet模式下关闭模态视图控制器的键盘 [英] iPad - Dismiss keyboard for modal view controller in UIModalPresentationFormSheet mode

查看:399
本文介绍了iPad - 在UIModalPresentationFormSheet模式下关闭模态视图控制器的键盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的iPad应用程序中,我想在 UIModalPresentationFormSheet 模式模式无键盘中呈现一些视图控制器。

In my iPad app I want to present some view controllers in UIModalPresentationFormSheet modal mode without keyboard.

我用它来显示帮助作为一个例子。

I use it to display help as an example.

目前我使用stackoverflow答案中的代码来解雇它:

At the moment I use the code found on the one of stackoverflow answers to dismiss it:

// trick to dismiss keyboard in iPad:    
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad){
        // iPad specific behaviour:

        @try
        {
            Class UIKeyboardImpl = NSClassFromString(@"UIKeyboardImpl");
            id activeInstance = [UIKeyboardImpl performSelector:@selector(activeInstance)];
            [activeInstance performSelector:@selector(dismissKeyboard)];
        }
        @catch (NSException *exception)
        {
            //NSLog(@"%@", exception);
        }

    }

但我担心Apple会拒绝它在审批过程中因为它使用私有API

But I am afraid Apple can reject it in during approval process as it uses private API

我可以看到 Apple开发人员在GarageBand帮助屏幕中实现了这一点所以它必须是'正确的方法。

I can see Apple developers achieved that in the GarageBand help screens so it must be the 'proper' way to do this.

我们的客户不希望因为这种轻微的限制而改变设计理念,我将不胜感激。

Would appreciate help as our client do not want to change design concept because of such a slight limitation.

更新:
就在今天,我被AppStore拒绝了:


我们发现您的应用使用了一个或多个
的非公开API,这不符合App Store Review
指南的b
。不允许使用非公共API
,因为如果这些
API发生变化,它可能导致
的用户体验不佳。

We found that your app uses one or more non-public APIs, which is not in compliance with the App Store Review Guidelines. The use of non-public APIs is not permissible because it can lead to a poor user experience should these APIs change.

我们在您的应用中发现了以下非公开API

We found the following non-public APIs in your app:

activeInstance dismissKeyboard

所以请不要遵循这个建议
如何从MODAL视图控制器隐藏iPad键盘?

推荐答案

正如我在上述问题的评论中所说:您可以使用NSSelectorFromString()动态构造选择器。这将被AppStore接受,您的错误将被修复,您的代码也不会崩溃。

As I said in a comment in the mentioned question: you can construct the selector dynamically with NSSelectorFromString(). This will be accepted for the AppStore, your bug will be fixed and your code will not crash.

这篇关于iPad - 在UIModalPresentationFormSheet模式下关闭模态视图控制器的键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆