4

I am trying to create a messaging interface, that is similar to the iOS messaging app. The part I am struggling with is overriding inputAccessoryView (on the view controller) is having no effect for me.

If you look at the link below, it shows a brief potential solution, without going into specifics.

The following link explains my question better than I could: http://robots.thoughtbot.com/input-accessorizing-uiviewcontroller

Here is an example of some things I have tried:

override func canBecomeFirstResponder() -> Bool {
    return true
}

override var inputAccessoryView: UIView! {
    return self.keyboardToolbar // Which is of type UIToolbar
    // I have also tried creating a toolbar here and returning it instead of the above approach, with no luck
}

I have also seen this question on SO: Swift inputAccessoryView override bug That shows it working for the user... suffice to say i have not managed to get anything to show up on the screen at present.

What am i doing wrong? Does anyone have a working snippet i could try?

Community
  • 1
  • 1
PersuitOfPerfection
  • 1,009
  • 1
  • 15
  • 28
  • Unlike forum sites, we don't use "Thanks", or "Any help appreciated", or signatures on [so]. See "[Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?](http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts). – John Saunders Jan 13 '15 at 13:19
  • Thanks John. Good to know. (hopefully it's ok to say thanks in comments ;) ) – PersuitOfPerfection Jan 13 '15 at 13:24
  • It is, because comments are considered ephemeral and comments like these may very well be deleted. – John Saunders Jan 13 '15 at 13:28
  • Thank you John we appreciate you're not answering but commenting about how not nice to say thank you stuff – fullmoon Aug 11 '17 at 20:39

2 Answers2

3

Turns out i was missing a:

self.becomeFirstResponder()

Now everything shows up.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
PersuitOfPerfection
  • 1,009
  • 1
  • 15
  • 28
  • iPhone worked fined without this call. iPad needs it for some reason (and the input view spans across the entire screen even in split view, not sure if that's normal but i'll deal with it) – Brad G Oct 01 '15 at 04:58
  • hey how did u solve ur problem, iam not able to display `inputAccessoryView` at bottom – Mukesh Jan 18 '16 at 12:51
1

For anyone else having this issue, I had to add this line to the UIView subclass returned by inputAccessoryView:

self.autoresizingMask = .flexibleHeight