Add custom UIButton to UIKeyboard's accessory view for a UIWebView

后端 未结 2 1879
天命终不由人
天命终不由人 2021-01-07 08:46

I need to add a camera button to a UIWebView\'s keyboard accessory view toolbar (the one that already has the \"Back|Next\" and \"Done\" buttons).

Is th

2条回答
  •  春和景丽
    2021-01-07 09:24

    there is an easier way to do this.

    Keep your keyboard notification in your viewDidLoad

    After that all you will need is the following method:

    -(void)keyboardDidShow:(NSNotification*)notif
    {
        NSArray *array = [[UIApplication sharedApplication] windows];
    
        for (UIWindow* wind in array) {
            for (UIView* currView in wind.subviews) {
                if ([[currView description] hasPrefix:@"

    I have basically taken the original prev/next buttons from the UIWebFormAccessory and added a done button to the end of it, but you can add what ever buttons you want to this.

    Some may think this shouldn't be implemented in -(void)keyboardDidShow: because you are changing the UI after it displays on screen, but so far I haven't noticed any issues with this. (only tested in simulator)

    Hope this was useful!

提交回复
热议问题