gpt4 book ai didi

ios - 如何在 ios 7 中删除键盘的顶部栏

转载 作者:塔克拉玛干 更新时间:2023-11-02 08:02:32 26 4
gpt4 key购买 nike

在我的程序中,我将 UIWebView 与可编辑的 div 一起用于富文本编辑器。我需要移除键盘的顶部栏。 enter image description here

我使用了下面的代码 - 它只删除了下一个/上一个按钮我想删除完整的顶部栏。

- (void)removeBar {
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}

for (UIView *possibleFormView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
}
}
}
}
}

最佳答案

我找到了适用于 iOS 8 的解决方案。您可以在这里查看:[ iOS 8 - Remove Previous/Next/Done UIKeyboard Toolbar inside a UIWebView][1]

您可以尝试改进它。尝试在您的 UIKeyboardDidShowNotification 事件处理程序中调用此函数。

希望对你有帮助...这是附件中的 View 级别:(UIWebFormAccessory) -> (UIToolbar) -> (UIImageView,UIToolbarButton,UIToolbarButton)

-(void) removeKeyboard {
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual : [UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}

// Locate UIWebFormView.
for (UIView *possibleFormView in [keyboardWindow subviews]) {

if ([[possibleFormView description] hasPrefix : @"<UIInputSetContainerView"]) {
for (UIView* peripheralView in possibleFormView.subviews) {

for (UIView* peripheralView_sub in peripheralView.subviews) {


// hides the backdrop (iOS 8)
if ([[peripheralView_sub description] hasPrefix : @"<UIKBInputBackdropView"] && peripheralView_sub.frame.size.height == 44) {
[[peripheralView_sub layer] setOpacity : 0.0];

}
// hides the accessory bar
if ([[peripheralView_sub description] hasPrefix : @"<UIWebFormAccessory"]) {


for (UIView* UIInputViewContent_sub in peripheralView_sub.subviews) {

CGRect frame1 = UIInputViewContent_sub.frame;
frame1.size.height = 0;
peripheralView_sub.frame = frame1;
UIInputViewContent_sub.frame = frame1;
[[peripheralView_sub layer] setOpacity : 0.0];

}

CGRect viewBounds = peripheralView_sub.frame;
viewBounds.size.height = 0;
peripheralView_sub.frame = viewBounds;

}
}

}
}


}
}

关于ios - 如何在 ios 7 中删除键盘的顶部栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20124149/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com