iPad - 在 UIModalPresentationFormSheet 模式下关闭模态视图控制器的键盘

发布于 2024-10-22 03:58:30 字数 1390 浏览 6 评论 0原文

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

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

目前,我使用在 stackoverflow 答案之一中找到的代码来驳回它:

// 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

我可以看到 Apple 开发人员在 GarageBand 帮助屏幕中实现了这一点 所以这一定是执行此操作的“正确”方法。

非常感谢您的帮助,因为我们的客户不想因为如此微小的限制而改变设计理念。

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

我们发现您的应用使用一个或 更多非公开API,不在其中 遵守 App Store 审查 指导方针。使用非公开 API 是不允许的,因为它可能导致 如果这些会导致糟糕的用户体验 API 发生变化。

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

activeInstance DismissKeyboard

因此,请不要遵循此建议如何隐藏 iPad 键盘来自 MODAL 视图控制器?

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.

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);
        }

    }

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

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.

UPDATE:
Just today I was rejected from AppStore:

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.

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

activeInstance dismissKeyboard

So please do NOT follow this advice:
How to HIDE the iPad keyboard from a MODAL view controller?

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

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

发布评论

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

评论(1

oО清风挽发oО 2024-10-29 03:58:30

正如我在上述问题的评论中所说:您可以使用 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文