Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/szweier/SZMentions
Library to help handle mentions
https://github.com/szweier/SZMentions
Last synced: 7 days ago
JSON representation
Library to help handle mentions
- Host: GitHub
- URL: https://github.com/szweier/SZMentions
- Owner: szweier
- License: mit
- Created: 2015-12-21T01:44:36.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2016-12-01T03:21:45.000Z (about 8 years ago)
- Last Synced: 2024-11-13T04:03:00.590Z (about 1 month ago)
- Language: Objective-C
- Size: 141 KB
- Stars: 11
- Watchers: 3
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
- awesome-ios-star - SZMentions - Library to help handle mentions. (Text / Other Testing)
- awesome-ios - SZMentions - Library to help handle mentions. (Text / Other Testing)
README
# SZMentions is no longer being updated, please use [SZMentionsSwift](https://github.com/szweier/SZMentionsSwift)
[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/SZMentions.svg)](https://img.shields.io/cocoapods/v/SZMentions.svg)
[![Platform](https://img.shields.io/cocoapods/p/SZMentions.svg?style=flat)](http://cocoadocs.org/docsets/SZMentions)
[![Twitter](https://img.shields.io/badge/[email protected]?style=flat)](http://twitter.com/StevenZweier)SZMentions is a lightweight mentions library for iOS. This library was built to assist with the adding, removing and editing of a mention within a textview.
## How To Get Started
- [Download SZMentions](https://github.com/szweier/SZMentions/archive/master.zip) and try out the iOS example app.
## Communication
- If you **need help**, feel free to tweet @StevenZweier
- If you **found a bug**, **have a feature request**, or **have a general question** open an issue.
- If you **want to contribute**, submit a pull request.## Installation with CocoaPods
[CocoaPods](http://cocoapods.org)
#### Podfile
To integrate SZMentions into your Xcode project using CocoaPods, specify it in your `Podfile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'pod 'SZMentions'
```Then, run the following command:
```bash
$ pod install
```## Requirements
| SZMentions Version | Minimum iOS Target |
|:--------------------:|:---------------------------:||
| 0.0.x | iOS 8.1 |## Usage
Below is a quick run through of the objects used in this library but as always the best place to get an understanding of the current implementation of the SZMentions library is in the example code.
#### SZMentionsListener
This class manages the mention interaction.
##### Setup
Use one of the many initializers to setup your mentions listener. Parameters explained below:`textView` : **required** The text view we are applying the mentions listener to. Note: it's delegate **must** be the mentions manager.
`mentionsManager` : **required** The class that will be handling the mention interaction.
`delegate` : **optional** If you would like to receive UITextView delegate methods set this and it will be passed through after processing view the mentions listener.
`defaultTextAttributes` : Attributes (see: `SZAttribute`) to apply to the textview for all text that is not a mention.
`mentionTextAttributes` : Attributes (see: `SZAttribute`) to apply to the textview for all mentions
`spaceAfterMention` : **optional** Whether or not you would like a space to be added to the end of your mentions. Default is `NO`
`trigger` : The string used to start a mention. Default is `@`
`cooldownInterval` : **optional** The amount of time to wait between calling showMentionsList. Default is `0.5`
##### Properties
`mentions` : **readonly** Array of all mentions currently applied to the text view.
##### Methods
`- (void)addMention:(NSObject *)mention;` : Call this method while adding a mention to apply the mention to the current text.
#### SZCreateMentionProtocol
This required properties for a mention being sent to the mentions listener
#### SZMentionsManagerProtocol
The require methods for handling mention interaction.
`- (void)showMentionsListWithString:(NSString *)mentionString;` lets the delegate know to show a mentions list as well as provides the current string typed into the textview, allowing for filtering of the mentions list.
`- (void)hideMentionsList;` lets the delegate know we are no longer typing in a mention.
#### SZMention
This class is returned via the `mentions` method, it includes the `range` of the mention as well as `object` containing the object sent to the mentions listener via the `addMention:(id)mention` method.
#### SZAttribute
This class is used to pass attributes to apply mentions text as well as regular text.
Example:
SZAttribute *attribute = [[SZAttribute alloc] initWithAttributeName:NSForegroundColorAttributeName
attributeValue:[UIColor redColor]];
## Unit Tests
SZMentions includes unit tests which can be run on the SZMentions framework
## Credits
SZMentions was originally created by [Steven Zweier](http://twitter.com/StevenZweier)