This repository has been archived by the owner on Aug 14, 2019. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
No opportunity to change JSQMessagesInputToolbar preferredDefaultHeight #1449
Comments
If anyone else is facing a similar problem here is a workaround. It isn't ideal but hopefully a real fix will be explored. Just add the extension below and set extension JSQMessagesViewController {
// MARK: - Properties
/**
The height for the input toolbar displayed at the bottom of the receiver's view.
This property can only be set after the view has loaded so that it can properly
modify the layout configuration since the documented variable for changing the default
toolbar height does not actually work since you can't set it in time for it to be used.
*/
var inputToolbarHeight: CGFloat {
get {
guard let inputToolbar = inputToolbar else {
return 0
}
return inputToolbar.preferredDefaultHeight
}
set(newValue) {
assert(isViewLoaded(), "Cannot set inputToolbarHeight before the view has been loaded.")
if isViewLoaded() == false {
return
}
guard let inputToolbar = inputToolbar else {
return
}
inputToolbar.preferredDefaultHeight = newValue
inputToolbarHeightConstraint?.constant = newValue
// since we have changed the constraint we need to force the entire view to layout
// so that the next function call will be able to calculate the correct frames
view.setNeedsUpdateConstraints()
view.setNeedsLayout()
view.layoutIfNeeded()
// doing this will cause an internal method jsq_updateCollectionViewInsets to be called
// which will ensure the collection view scroll is right based on the new toolbar height
let originalTopContentAdditionalInset = topContentAdditionalInset
topContentAdditionalInset = originalTopContentAdditionalInset
}
}
// MARK: - Private Properties
/**
The height constraint for the inputToolbar, or nil if the constraint could not be resolved.
*/
private var inputToolbarHeightConstraint: NSLayoutConstraint? {
get {
if let inputToolbar = inputToolbar {
for constraint: NSLayoutConstraint in inputToolbar.constraints {
if constraint.firstAttribute == NSLayoutAttribute.Height {
return constraint
}
}
}
return nil
}
}
} |
GuyKahlon
pushed a commit
to GuyKahlon/JSQMessagesViewController
that referenced
this issue
Mar 1, 2016
…Toolbar preferredDefaultHeight. It doesn't seem like you can change the height of the inputToolbar using the documented property preferredDefaultHeight since it is used to configure the height constraint in viewDidLoad. In order to fix the bug I added the line of code: self.toolbarHeightConstraint.constant = self.inputToolbar.preferredDefaultHeight; In the method: - (void)jsq_updateKeyboardTriggerPoint This function called from viewWillAppear and the view load with the correct constraints. I'm not really sure if it's the optimal location for this line of code, alternative location is just to call from viewWillAppear.
GuyKahlon
pushed a commit
to GuyKahlon/JSQMessagesViewController
that referenced
this issue
Mar 1, 2016
…Toolbar preferredDefaultHeight. It doesn't seem like you can change the height of the inputToolbar using the documented property preferredDefaultHeight since it is used to configure the height constraint in viewDidLoad. In order to fix the bug I added the line of code: self.toolbarHeightConstraint.constant = self.inputToolbar.preferredDefaultHeight; In the method: viewWillAppear, and now the view load with the correct constraints.
GuyKahlon
added a commit
to GuyKahlon/JSQMessagesViewController
that referenced
this issue
Mar 2, 2016
…Toolbar preferredDefaultHeight.
GuyKahlon
pushed a commit
to GuyKahlon/JSQMessagesViewController
that referenced
this issue
Mar 3, 2016
It doesn't seem like you can change the height of the inputToolbar using the documented property preferredDefaultHeight since it is used to configure the height constraint in viewDidLoad. In order to fix the bug I added the line of code: self.toolbarHeightConstraint.constant = self.inputToolbar.preferredDefaultHeight; In the method: viewWillAppear, and now the view load with the correct constraints.
Closed
GuyKahlon
pushed a commit
to GuyKahlon/JSQMessagesViewController
that referenced
this issue
Mar 3, 2016
…t of the inputToolbar using the documented property preferredDefaultHeight since it is used to configure the height constraint in viewDidLoad. In order to fix the bug I added the line of code: self.toolbarHeightConstraint.constant = self.inputToolbar.preferredDefaultHeight; In the method: viewWillAppear, and now the view load with the correct constraints.
lbanders
added a commit
to TeletronicsDotAe/JSQMessagesViewController
that referenced
this issue
Mar 8, 2016
…ps://github.com/TeletronicsDotAe/JSQMessagesViewController into tlt-issue1458-support-scrolling-to-last-message * 'tlt-issue1458-support-scrolling-to-last-message' of https://github.com/TeletronicsDotAe/JSQMessagesViewController: Update ISSUE_TEMPLATE.md Update ISSUE_TEMPLATE.md 1. fix a typo of JSQMessagesTimestampFormatterTests.m 2. remove one line unused code of JSQMessagesViewController.m Bug jessesquires#1449 - It doesn't seem like you can change the height of the inputToolbar using the documented property preferredDefaultHeight since it is used to configure the height constraint in viewDidLoad. clean up Update contributor_onboarding.md marked designated initializers where applicable (issue jessesquires#1142) fixed typos in the onboarding guide Update README.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md
lbanders
pushed a commit
to TeletronicsDotAe/JSQMessagesViewController
that referenced
this issue
Mar 8, 2016
…t of the inputToolbar using the documented property preferredDefaultHeight since it is used to configure the height constraint in viewDidLoad. In order to fix the bug I added the line of code: self.toolbarHeightConstraint.constant = self.inputToolbar.preferredDefaultHeight; In the method: viewWillAppear, and now the view load with the correct constraints.
lbanders
added a commit
to TeletronicsDotAe/JSQMessagesViewController
that referenced
this issue
Mar 8, 2016
…ps://github.com/TeletronicsDotAe/JSQMessagesViewController into tlt-issue1458-support-scrolling-to-last-message * 'tlt-issue1458-support-scrolling-to-last-message' of https://github.com/TeletronicsDotAe/JSQMessagesViewController: (21 commits) jessesquires#1458 Updated according to review comments. Springiness re-enabled on demo app jessesquires#1458 implemented. Update ISSUE_TEMPLATE.md Update ISSUE_TEMPLATE.md 1. fix a typo of JSQMessagesTimestampFormatterTests.m 2. remove one line unused code of JSQMessagesViewController.m Bug jessesquires#1449 - It doesn't seem like you can change the height of the inputToolbar using the documented property preferredDefaultHeight since it is used to configure the height constraint in viewDidLoad. clean up Update contributor_onboarding.md marked designated initializers where applicable (issue jessesquires#1142) fixed typos in the onboarding guide Update README.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md Update contributor_onboarding.md ...
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
It doesn't seem like you can change the height of the
inputToolbar
using the documented propertypreferredDefaultHeight
since it is used to configure the height constraint inviewDidLoad
. Am I missing something or is this an actual issue. Thanks.The text was updated successfully, but these errors were encountered: