Skip to content
This repository has been archived by the owner on Oct 30, 2018. It is now read-only.

Open autocompletion with prefix #506

Merged
4 commits merged into from
Aug 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Source/SLKTextViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ NS_CLASS_AVAILABLE_IOS(7_0) @interface SLKTextViewController : UIViewController
*/
- (void)showAutoCompletionView:(BOOL)show;


/**
Use this method to programatically show the autocompletion view, with provided prefix and word to search.
Right before the view is shown, -reloadData is called. So avoid calling it manually.

@param prefix a prefix that is used to trigger autocompletion
@parm word a word to search for autocompletion
*/
- (void)showAutoCompletionViewWithPrefix:(NSString *)prefix andWord:(NSString *)word;

/**
Returns a custom height for the autocompletion view. Default is 0.0.
You can override this method to return a custom height.
Expand Down
10 changes: 10 additions & 0 deletions Source/SLKTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,16 @@ - (void)showAutoCompletionView:(BOOL)show
animations:NULL];
}

- (void)showAutoCompletionViewWithPrefix:(NSString *)prefix andWord:(NSString *)word;
{
if ([self.registeredPrefixes containsObject:prefix]) {
_foundPrefix = prefix;
_foundWord = word;
[self didChangeAutoCompletionPrefix:self.foundPrefix andWord:self.foundWord];
[self showAutoCompletionView:YES];
}
}

- (void)acceptAutoCompletionWithString:(NSString *)string
{
[self acceptAutoCompletionWithString:string keepPrefix:YES];
Expand Down