sumitjagdev / SJTwitterTagInputTextView翻译 / 编辑

最近提交:8月前
创建时间:2016.12.27

语言构成

Swift96.7%
Ruby3.3%

README

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.

讨论区

说说你的看法