Skip to content

SJTwitterTagInputTextView is a subclass of UIView, written in Swift, that enables the UIView to use as the "#" and "@" tag input view with suggestion list.

License

Notifications You must be signed in to change notification settings

sumitjagdev/SJTwitterTagInputTextView

Repository files navigation

SJTwitterTagInputTextView

[![CI Status](http://img.shields.io/travis/Sumit Jagdev/SJTwitterTagInputTextView.svg?style=flat)](https://travis-ci.org/Sumit Jagdev/SJTwitterTagInputTextView) Version License Platform

Overview

SJTwitterTagInputTextView is a subclass of UIView, written in Swift, that enables the UIView to use as the "#" and "@" tag input view with suggestion list.

Requirements

  • ARC
  • iOS8

Example

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

Requirements

Installation

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

pod "SJTwitterTagInputTextView"

Usage

import SJTwitterTagInputTextView

@IBOutlet var tagInputView : SJTwitterTagInputTextView!
tagInputView.delegate = self

//TODO : Please add height constraint and set id of constraint = "SJTextViewHeight"
//MARK : SJTwitterTagInputTextViewDelegate
    func didSearchWithAtTag(tagString: String) {
        //        print("Current Search Word @ : ", tagString)
        
        let predicate = NSPredicate(format: "SELF contains[cd] %@", tagString)
        let array = allObjectList as NSArray!
        let newArray = array.filteredArrayUsingPredicate(predicate)
        
        tagInputView.allObjectList = newArray as! [String]
        
    }
    
    func didSearchWithHashTag(tagString: String) {
        //        print("Current Search Word # : ", tagString)
        
        let predicate = NSPredicate(format: "SELF contains[cd] %@", tagString)
        let array = allObjectList as NSArray!
        let newArray = array.filteredArrayUsingPredicate(predicate)
        
        tagInputView.allObjectList = newArray as! [String]
    }
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        print("All @ Tags : ", tagInputView.getAllAtTags())
        print("All # Tags : ", tagInputView.getAllHashTags())
    }

Author

Sumit Jagdev, sumitjagdev3@gmail.com

License

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

About

SJTwitterTagInputTextView is a subclass of UIView, written in Swift, that enables the UIView to use as the "#" and "@" tag input view with suggestion list.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published