Giter Club home page Giter Club logo

avtagtextview's Introduction

AVTagTextView

Version Platform

A category that adds an instragram-like hashtag choosing/listing capability to the UITextView.

Screencapture GIF

Installation

AVTagTextView is available through CocoaPods, to install it simply add the following line to your Podfile:

pod "AVTagTextView"

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>

Usage

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.

Example

To run the example project; clone the repo, and run pod install from the Project directory first.

Requirements

  • ReactiveCocoa. The category strongly relies on the capabilities of ReactiveCocoa library to react on the user's input and to properly handle the keyboard's hiding/showing notifications.
  • iOS 6.1 or greater

Tests

The project includes a Kiwi spec that can be found in the Tests folder

TODO

  1. Remove ReactiveCocoa as a dependency.

Author

Arseniy Vershinin

License

AVTagTextView is available under the MIT license. See the LICENSE file for more info.

avtagtextview's People

Contributors

arsonic avatar

Watchers

Orlando avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.