InputAccessoryView with custom view created in IB
NickName:Raymond Ask DateTime:2020-06-12T22:12:27

InputAccessoryView with custom view created in IB

I've read a lot of material on this topic but most of them create custom view programatically.

Is it possible to use InputAccessoryView with a custom view created in IB? In storyboard I've added textInputView, inside which I've added text view and send button etc as seen in the screenshot below.

I've following code so which removes Table View for some reason so I can't get it working. I've added tableview in the storyboard.

I've shown here only InputAccessoryView related code.

class InputAccViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

    @IBOutlet weak var tableView: UITableView!
    @IBOutlet weak var textView: UITextView!
    @IBOutlet weak var textInputView: UIView!
    // other code

    override var canBecomeFirstResponder: Bool { return true }

    override var inputAccessoryView:UIView {
       get{
           return self.textInputView
       }
   }

    override func viewDidLoad() {
        super.viewDidLoad()

        textInputView.removeFromSuperview()
        // other code
    }
     // other code tableview delegates etc...
}

Left screenshot is with the accessory view code which doesn't show table view. If I comment out accessory view related code it does show table view as in the right screenshot.

enter image description here

Copyright Notice:Content Author:「Raymond」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/62346077/inputaccessoryview-with-custom-view-created-in-ib

More about “InputAccessoryView with custom view created in IB” related questions

InputAccessoryView with custom view created in IB

I've read a lot of material on this topic but most of them create custom view programatically. Is it possible to use InputAccessoryView with a custom view created in IB? In storyboard I've added

Show Detail

iOS -custom xib file not appearing as inputAccessoryView of UITextField

I'm following this video (except im linking the custom view in code not in IB), but I'll explain what's happening. I have created a custom view that extends off UiView. It is created from an xib fi...

Show Detail

inputAccessoryView with custom view hide After I Dismiss keyboard

First of all , my project is so structured: -home page with a tableView to add element -floating Button: when clicked make appear keyboard with above a custom view (and inside a textView) to digit ...

Show Detail

Custom Button created in IB does not allow access to custom methods

I have an iOS app with multiple ViewControllers. Each view has numerous IB generated UIButtons, each set to custom. I need to change the color of the background in normal and highlighted states.

Show Detail

Custom UIView in IB

I have created a custom subclass of UIView for an interface element that I want to create on an iPad screen. (it creates a list of buttons) To use this view, I have added a view in IB, set the size

Show Detail

Animating a view created in IB using Autolayout

I have a view with a lot of labels and buttons which are created on code because in IB is too complicated. This works ok. In IB I also created an input view which I want to appear from the bottom ...

Show Detail

Custom view using code or IB

Is there a right/wrong approach for creating a Custom view using code or IB? I mean what should be the preferred way of designing a custom view.

Show Detail

How to remove inputAccessoryView and replace it with another view?

Here is the requirement Basic chat app that has an input accessory view on top of keyboard in a UICollectionViewController I add this custom input accessory view by using override var inputAccesso...

Show Detail

Why is UIResponder inputAccessoryView atomic?

I'm using inputAccessoryView for one of my custom subclasses of UIViewController, which subclasses UIResponder. The Apple Developer Class Reference for -[UIResponder inputAccessoryView] states:

Show Detail

How to get a custom UITableViewCell class created in IB to load into a UITableView?

I am new to this so please bear with me: I have a .xib in IB containing a UIScrollView that has a UITableView embedded in it. I would like to load custom UITableViewCells into the UITableView. I...

Show Detail