在 iOS 9 中隐藏 copy/paste/return 面板(快捷方式面板)

Hiding copy/paste/return panel in iOS 9 (Shortcuts panel)

我正在 iOS 9 Beta 上测试我的应用程序。 Apple 添加了具有 copy/paste/return 功能的新面板。

我知道我可以在设备的常规设置中禁用它。

我可以使用通知在代码中检测到它吗?我可以告诉我的 textFields 和 textViews 在编辑时不显示吗?

如果我关闭预测视图,面板将显示。

我在 xCode 7 beta 4 中没有找到它。如果您知道如何解决这个问题,请也告诉我:)

试试这个

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
    if (action == @selector(paste:))
        return NO;
    return [super canPerformAction:action withSender:sender];
}

希望对您有所帮助。

我已经解决了这个问题。我找到了以编程方式隐藏此快捷方式栏的方法:

if ([textView respondsToSelector:@selector(inputAssistantItem)])
{
    UITextInputAssistantItem *inputAssistantItem = [textView inputAssistantItem];
    inputAssistantItem.leadingBarButtonGroups = @[];
    inputAssistantItem.trailingBarButtonGroups = @[];
}

如果需要,您还可以检测 iOS 版本。 重要的是要知道 UITextInputAssistantItem class 是新的 class for iOS 9.

if ([[[UIDevice currentDevice] systemVersion] intValue] > 8.99)
{
    // Your super-code
}

希望这是有用的信息!