Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling reloadInputAccessoryView after view is collapsed causes a crash #12

Open
reygonzales opened this issue May 22, 2014 · 9 comments

Comments

@reygonzales
Copy link

The app crashes if the input view is reloaded (with reloadInputAccessoryView) when the view is collapsed.

- (void)_updateInputViewFrameWithKeyboardFrame:(CGRect)keyboardFrame
                                   forceReload:(BOOL)reload
{
    // If the keyboardFrame equals CGRectZero and
    // the inputView is not visible yet, we won't be able
    // to access the keyboard's frame.
     #ifdef DEBUG
          NSCAssert(!(CGRectEqualToRect(keyboardFrame, CGRectZero) &&
                self.inputView.superview == nil), nil);
     #endif

I need to refresh the view when it is collapsed -- the user can still hit "Send"

Stack trace

2014-05-22 14:09:19.250 NearKat[21012:60b] *** Assertion failure in -RDRStickyKeyboardView _updateInputViewFrameWithKeyboardFrame:forceReload:, /Users/reynaldo/Documents/Workspace/nearkat-ios/Pods/RDRStickyKeyboardView/RDRStickyKeyboardView/RDRStickyKeyboardView.m:754
2014-05-22 14:09:19.255 NearKat[21012:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: ''
*** First throw call stack:
(
0 CoreFoundation 0x039bc1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x032ba8e5 objc_exception_throw + 44
2 CoreFoundation 0x039bc048 +[NSException raise:format:arguments:] + 136
3 Foundation 0x017f5b20 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 101
4 NearKat 0x0023beec -[RDRStickyKeyboardView _updateInputViewFrameWithKeyboardFrame:forceReload:] + 572
5 NearKat 0x00238a60 -[RDRStickyKeyboardView reloadInputAccessoryView] + 96

@datwelk
Copy link
Owner

datwelk commented May 22, 2014

Multiple people have reported this already and it obviously has to do with the assert but I did put that assert there for a reason. I haven't been able to reproduce the crash myself, do you have a sample project I can take a look at by any chance?

@reygonzales
Copy link
Author

I don't have sample code but its pretty easy to replicate

  1. Write text in inputView
  2. Collapse view
  3. Call [self.contentWrapper reloadInputAccessoryView];

@datwelk
Copy link
Owner

datwelk commented May 22, 2014

That function does no longer exist. Does it help to use the latest code from the master branch?

@reygonzales
Copy link
Author

Ah, I'm using a cocoapod

I'll update my cocoa pod to point to master and see if its still a problem.

@reygonzales
Copy link
Author

Well, it doesn't crash now that I don't have access to it.

So how do I reset the size of the text view now?

(Thanks by the way, this library is awesome)

screen shot 2014-05-22 at 2 54 35 pm

@datwelk
Copy link
Owner

datwelk commented May 22, 2014

Thanks, I try :-)

What exactly do you want to achieve? I assume you pressed the return key several times and collapsed the keyboard afterwards, which causes the textview to keep its height to accommodate for the linebreaks. This behavior can be found in apps such as Whatsapp as well, except that Whatsapp does not allow a linebreak character as the first character in the textview. If that is what you want in your app, you could implement inputViewKeyboard.textView's delegate.

@reygonzales
Copy link
Author

👍

This is what I did

1: Type text in the text field

     Peanut butter
     AND
     Jelly!

2: "Send" the text to the server
3: Clear the text view


In a way I'm trying to get it to behave like the messages app when you're sending a paragraph to someone. After its sent, the text view shrinks to one line

@datwelk
Copy link
Owner

datwelk commented May 24, 2014

Ah, that makes sense. Will think about a solution. Feel free to file a pull request when you've found a (neat) solution yourself.

@seancrowe5
Copy link

Hey @reygonzales did you ever find a workaround for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants