问题描述
在我的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
:
We found the following non-public APIs in your app:
activeInstance dismissKeyboard
所以请不要遵循这个建议:
推荐答案
正如我在上述问题的评论中所说:您可以使用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模式下关闭模态视图控制器的键盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!