How to find UIWebView toolbar (to replace them) on iOS 6?(如何在 iOS 6 上找到 UIWebView 工具栏(以替换它们)?)
本文介绍了如何在 iOS 6 上找到 UIWebView 工具栏(以替换它们)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从另一个应用程序中尝试了以下代码,但没有找到任何东西.为什么?如何访问 UIWebView
工具栏?
I have tried the following code from another application but it doesn't find anything. Why? How to get access to the UIWebView
toolbar?
- (UIToolbar *)findVirginWebKeyboardToolbar:(UIView *)parent
{
if ([parent isKindOfClass:[UIToolbar class]]) {
UIToolbar *tb = (UIToolbar *)parent;
if ([tb.items count] == 1 && [((UIBarButtonItem *)[tb.items objectAtIndex:0]).customView isKindOfClass:[UISegmentedControl class]]) {
return tb;
}
}
for (UIView *view in parent.subviews) {
UIToolbar *tb = [self findVirginWebKeyboardToolbar:view];
if (tb) return tb;
}
return nil;
}
- (void)removeKeyboardBar {
UIView *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
keyboardWindow = testWindow;
UIToolbar *toolbar = [self findVirginWebKeyboardToolbar:keyboardWindow/*subviewWhichIsPossibleFormView*/];
if (toolbar) {
itemsArray = [NSArray arrayWithObjects:button1, button2, button3, nil];
[toolbar setItems:itemsArray];
}
}
}
推荐答案
通过以下代码,您应该能够移除键盘上方的工具栏.
With the following code you should be able to remove the toolbar that is above the keyboard.
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
}
- (void)keyboardWillShow:(NSNotification *)note {
[self performSelector:@selector(removeBar) withObject:nil afterDelay:0];
}
- (void)removeBar {
// Locate non-UIWindow.
UIWindow *keyboardWindow = nil;
for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
if (![[testWindow class] isEqual:[UIWindow class]]) {
keyboardWindow = testWindow;
break;
}
}
// Locate UIWebFormView.
for (UIView *formView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[formView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subView in [formView subviews]) {
if ([[subView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
// remove the input accessory view
[subView removeFromSuperview];
}
else if([[subView description] rangeOfString:@"UIImageView"].location != NSNotFound){
// remove the line above the input accessory view (changing the frame)
[subView setFrame:CGRectZero];
}
}
}
}
}
这篇关于如何在 iOS 6 上找到 UIWebView 工具栏(以替换它们)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:如何在 iOS 6 上找到 UIWebView 工具栏(以替换它们)?
基础教程推荐
猜你喜欢
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01