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

[UI Fix] Setting up the initial frame of the textview only when the mana... #29

Merged
merged 2 commits into from
Mar 11, 2014

Conversation

esttorhe
Copy link
Contributor

...ger is enabled and we have the flag to adjust the text view.

The manager was resetting the frame of the textfield even when the manager was disabled.

Signed-off-by: Esteban Torres me@estebantorr.es

…anager is enabled and we have the flag to adjust the text view.

The manager was resetting the frame of the textfield even when the manager was disabled.

Signed-off-by: Esteban Torres <me@estebantorr.es>
@esttorhe
Copy link
Contributor Author

@hackiftekhar I added this because we were using this on a project where we were modifying the frame of some textviews depending on the text in them and even though we were using this library somewhere else; turning it off was causing issues because this library resets the "original" frame of the textfield even when the library is disabled.

@hackiftekhar
Copy link
Owner

Thanks for pull request,
I have 1 query regarding this.
Suppose KeyboardManager is enabled and canAdjustTextView is also YES. Suppose a textView is become first responder. Then the keyboardManager will definitely adjust the textView's frame. and suppose when the textView is the firstResponder and you disable the keyboardManager or canAdjustTextView flag to NO. then the textView frame will not reset due to your condition.

    if(_enable  && _canAdjustTextView)

So the best way to reset textView's original frame is to capture the frame in textFieldViewDidBeginEditing and at the end when textFieldViewDidEndEditing the original frame which was saved during the textViewDidBeginEditing is restored even if the keyboardManager is enable or not or the canAdjustTextView flag is YES or NO, no matters.

But I understand what actual problem you are facing right now. We have to find out a generic solution for this. If you have a better idea I would love to hear from you.

Regards
Iftekhar

@esttorhe
Copy link
Contributor Author

I see what you mean @hackiftekhar
Then I would check on textViewDidBeginEditing if it's enabled and canAdjustView and save the textfield there but if is not then don't save the textfield.

That way if it gets disabled while editing it will still reset the frame and if it was disabled on textViewDidBeginEditing the textfield will be set as nil and on textViewDidEndEditing it will set the frame on a nil variable and it won't matter.

That way it will handle all you proposed scenarios as well as mine.

What do you think of this approach?

@hackiftekhar
Copy link
Owner

My proposed terms

  1. Check for enable and canAdjustTextView boolean in textViewDidBeginEditing
    if true
    then initialize textFieldViewIntialFrame with textField frame
    else
    then initialize textFieldViewIntialFrame as CGRectZero

  2. On textFieldDidEndEditing check textFieldViewInitialFrame is CGRectZero or not.
    if false
    then adjust textField frame
    else
    Nothing

How about this approach?

@esttorhe
Copy link
Contributor Author

Yeah; that's pretty much the same I proposed but setting the frame to zero vs setting the text filed to nil :)

I'll change the pull request in a few if you want and then you can just merge it. 

Sent from Mailbox for iPad

On Mon, Mar 10, 2014 at 9:56 PM, Mohd Iftekhar Qurashi
notifications@github.com wrote:

My proposed terms

  1. Check for enable and canAdjustTextView boolean in textViewDidBeginEditing
    if true
    then initialize textFieldViewIntialFrame with textField frame
    else
    then initialize textFieldViewIntialFrame as CGRectZero
  2. On textFieldDidEndEditing check textFieldViewInitialFrame is CGRectZero or not.
    if false
    then adjust textField frame
    else
    Nothing

How about this approach?

Reply to this email directly or view it on GitHub:
#29 (comment)

…ial frame to CGRectZero if is not enabled).

Signed-off-by: Esteban Torres <me@estebantorr.es>
@esttorhe
Copy link
Contributor Author

@hackiftekhar I just updated the pull request; see if it fits correctly with your code.

hackiftekhar added a commit that referenced this pull request Mar 11, 2014
[UI Fix] Setting up the initial frame of the textview only when the mana...
@hackiftekhar hackiftekhar merged commit 2509a57 into hackiftekhar:master Mar 11, 2014
@hackiftekhar
Copy link
Owner

Perfect (for pull request).
But the both proposals was not same brother. I am extracting all the window coordinate, textField position, textField siblings, and the expected View's frames, scrollView contentOffset via the textField object only. If we will try to set textFieldView = nil, then nothing will work.

Many thanks for the bug report and the contribution to this library.

Thanks
Iftekhar

@esttorhe
Copy link
Contributor Author

Yeah; probably I spoke too soon about the approaches being the same; truth be told I did not read thoughtfully the whole manager and that caused me to badly asses the solution.

Thanks for the merge; keep up with the good work.

Could you let me know when you update the Pod ?
I'm using your library but I had to comment out the code because of the bug.

Thanks

@hackiftekhar
Copy link
Owner

Will update soon.

@esttorhe
Copy link
Contributor Author

Hey @hackiftekhar just wondering if there's an ETA for the Pod update; I just need to know if this is happening soon or if I need to remove it from our project.

No pressure I just need to know if I need to make a custom solution instead of using IQKeyboardManager

@hackiftekhar
Copy link
Owner

You are free to update the pod file as well. This will also save my time.

Thanks
Iftekhar

@esttorhe
Copy link
Contributor Author

ok @hackiftekhar can you create a new tag pointing to 3.0.2 that matches the new podspec definition then.
I'll update the podspec and will wait for your tag before pushing it.

Thanks

@hackiftekhar
Copy link
Owner

Sure

@hackiftekhar
Copy link
Owner

Tag created pointing to 3.0.2.

@hackiftekhar
Copy link
Owner

Thanks for updating podspec

@esttorhe
Copy link
Contributor Author

Np. My pleasure to be of any help.

hackiftekhar added a commit that referenced this pull request Jul 12, 2016
[UI Fix] Setting up the initial frame of the textview only when the mana...

Former-commit-id: 2509a57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants