How to programmatically set the frame for a Custom Chooser view?
Apocryphon opened this issue · 3 comments
When creating a Custom Chooser view, it looks like the HKWMentionsCreationStateMachine
calls createNewChooserView
that sets the chooserFrame
to CGRectZero
for custom HKWMentionsChooserPositionMode
. The custom chooserView
is always created via that method, and in the static factory creation methods, chooserViewWithFrame:
always sets that frame to CGRectZero
.
I have a MYCustomChooserView
that implements chooserViewWithFrame:delegate:dataSource:
as part of HKWChooserViewProtocol
. In that custom view, I simply set the frame to the one received. However, that frame is always size zero, and the delegate
and dataSource
are always the same instance of the HKWMentionsCreationStateMachine
, which is part of the library. So how do I actually set those properties? Do I have to subclass HKWMentionsCreationStateMachine
?
The demo project is no help; it uses uses non-custom mode HKWMentionsChooserPositionModeEnclosedTop
, and so does not illustrate how we actually implement a custom chooser view.
Also, it lacks #import "HakawaiDemo-Swift.h"
at the top of MentionsDemoViewController.m
, so uncommenting the custom chooser view code will not compile.
Looks like the answer is hidden away in the Mentions APIs page, which mentions setChooserTopLevelView:attachmentBlock:
. The solution then is:
[_myMentionsCell.mentionsPlugin setChooserTopLevelView:self.view
attachmentBlock:^(UIView *view) {
MYCustomChooserView *chooserView = (MYCustomChooserView *)view;
typeof(self) strongSelf = weakSelf;
if (strongSelf) {
[chooserView setFrame:...];
}
}];
It still seems strange that for custom chooser modes, the frame that's getting passed into the factory method is always CGRectZero
.
Hi @Apocryphon : Do you know.. How can we increase height of selection list view out side the textview.