How to replace buttons on a toolbar under UIWebView keyboard on iOS 6?

霸气de小男生 提交于 2019-12-06 08:36:58

UIWebFormAccessory is no longer a UIToolbar on iOS6. It contains the UIToolbar you're looking for, though. Use something like the following to find it on either OS version...

+ (UIToolbar *)findVirginWebKeyboardToolbar:(UIView *)parent
{
    if ([parent isKindOfClass:[UIToolbar class]]) {
        // the stock toolbar contains a single item with a UISegmentedControl customView.
        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;
}

Use the following code to remove unused toolbar:

 [subviewWhichIsPossibleFormView removeFromSuperview];

And add a new one. Sorry, no code available.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!