whichappMHdetector
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Description
whichappMHdetector can detect @
and #
while you are typing or even if you move back cursor to a mention or hashtag word area and then you can edit it.
Usage
1- Import whichappMHdetector
import UIKit
import whichappMHdetector
2- make an instance of mentionHashtagDetector and set the delegates
//Making instance
let mentionHashtag = mentionHashtagDetector()
override func viewDidLoad() {
super.viewDidLoad()
///Setting Delegates:
//UITextView Delegate
textView.delegate = self
//mentionHashtagDetector Delegate
mentionHashtag.delegate = self
}
3- call detectSign function each time text change, simply calling this function under textViewDidChange
extension ViewController:UITextViewDelegate {
func textViewDidChange(_ textView: UITextView) {
///send every change in UITextView to the mentionHashtagDetector
mentionHashtag.detectSign(textView: textView)
}
}
4- listen to mentionHashtagDetectorDelegate
///Response of mentionHashtagDetector
extension ViewController:mentionHashtagDetectorDelegate {
func didSignDetected(_ text: String, _ signType: signTypeModels) {
//Print("\(text) Type=> \(signType)")
}
}
5- Done :)
Installation
whichappMHdetector is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'whichappMHdetector'
Author
sajjadsarkoobi, [email protected]
License
whichappMHdetector is available under the MIT license. See the LICENSE file for more info.