TestsTested | ✓ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Unclaimed.
A category that adds an instragram-like hashtag choosing/listing capability to the UITextView.
Alternatively you can drop the "Classes" folder into your project that should have the ReactiveCocoa library installed
Import the category:
#import <AVTagTextView/UITextView+AVTagTextView.h>
Assign the hashTagsDelegate property to the desired delegate and implement the tagsForQuery method:
self.textView.hashTagsDelegate = self;
//...
/**
* As soon as the user enters some symbols after the last '#' sign, this method gets called.
* Entered symbols are contained in the query string. It is your responsibility to provide
* the text view with the list of the corresponding hashtags as an array of strings:
*/
- (NSArray *)tagsForQuery:(NSString *)query{
//Provide the list of the tag, you wish to display to the user:
//For example, return the tags, which start with the query string, from the predefined array:
NSPredicate *bPredicate =
[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", query];
NSArray *array = [self.tagsArray filteredArrayUsingPredicate:bPredicate];
return array;
}
Hashtags, contained in the UITextView, can be accessed through its hashTags property:
self.textView.hashTags //returns an array of strings, corresponding to the hash tags, found in the UITextView's text
The default UITableViewController that displays the tags can be replaced with your custom UITableViewController implementation that has to conform to the AVTagTableViewProtocol. See the exemplary AVCustomTagTableViewController class.
To run the example project; clone the repo, and run pod install
from the Project directory first.
The project includes a Kiwi spec that can be found in the Tests folder
Arseniy Vershinin
AVTagTextView is available under the MIT license. See the LICENSE file for more info.