This pod provides a view controller for choosing and creating tags in the style of wordpress or tumblr.

Related tags

Tag PARTagPicker
Overview

PARTagPicker

This pod provides a view controller for choosing and creating tags in the style of wordpress or tumblr. This tag picker was originally used in the Intrepid Pursuits app, Slate.

DEMO

As used in Slate:

DEMO IN SLATE DEMO IN SLATE

From example project:

DEMO IN EXAMPLE DEMO IN EXAMPLE

Installation

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

pod 'PARTagPicker'

Usage

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

Include #import <PARTagPicker/PARTagPickerViewController.h>.

The basic setup is to create an instance of PARTagPickerViewController, add it's view, and then add the controller as a child view controller.

The tags are passed in as NSString objects in an array. Anytime you change the allTags array, any existing chosenTags are updated to use references to the new strings if they contain a match in the updated array. Otherwise they continue to point to the old strings.

Swift

override func viewDidLoad() {
    super.viewDidLoad()
    // Add the controller and view.
    let tagController = PARTagPickerViewController()
    addChildViewController(tagController)
    tagController.view.frame = CGRect(x: 0, y: 64, width: view.bounds.width, height: COLLECTION_VIEW_HEIGHT)
    view.addSubview(tagController.view)
    tagController.didMove(toParentViewController: self)

    // Customize appearance and data.
    tagController.delegate = self
    tagController.allTags = ["one fish","two fish"," red fish", "blue fish"]
    tagController.chosenTags = ["with a fox", "in a box", "anywhere"]
    tagController.allowsNewTags = true
    tagController.view.backgroundColor = .orange
    let colors = PARTagColorReference()
    colors.highlightedTagTextColor = .white
    colors.highlightedTagBackgroundColor = .blue
    tagController.tagColorRef = colors
}

func tagPicker(_ tagPicker: PARTagPickerViewController!, visibilityChangedTo state: PARTagPickerVisibilityState) {
    var newHeight: CGFloat = 0
    if state == .topAndBottom {
        newHeight = 2 * COLLECTION_VIEW_HEIGHT
    } else if state == .topOnly {
        newHeight = COLLECTION_VIEW_HEIGHT
    }

    var frame = tagPicker.view.frame
    frame.size.height = newHeight

    UIView.animate(withDuration: 0.3) {
        tagPicker.view.frame = frame
    }
}

Obj-C

See example with pod try PARTagPicker or check the example view controller here: https://github.com/paulrolfe/PARTagPicker/blob/master/PARTagPicker/ViewController.m

Options

  • You can customize colors using a PARTagColorReference object.
  • You can allow new tags with allowsNewTags boolean property on the controller.
  • You can set the chosenTags directly.
  • Delegate methods for when the chosenTags change and the tag picker changes size.
  • - (void)tagPicker:(PARTagPickerViewController *)tagPicker visibilityChangedToState:(PARTagPickerVisibilityState)state
  • - (void)chosenTagsWereUpdatedInTagPicker:(PARTagPickerViewController *)tagPicker
  • tapToEraseTags Defaults to YES. If set to NO, tapping a cell will just select it (not delete it).
  • placeholderText - The default text to have as placeholder text in each tag cell. Default value is @"Add a tag".

Notes

This is still a work in progress. If you have suggestions or run into issues, please create an issue on git or tweet me @ThePaulRolfe.

Updates

  • v1.4.0 - Swift example, expose cleaner PARTagColorReference init.
  • v1.1.0 - Added properties for placeholderText and tapToEraseTags.
  • v1.0.4 - Enabled for use in swift pods.
  • v1.0.2 - Including .xibs in the pod now. Oops!
  • v1.0.0 - Added documentation and fixed bug with deselecting chosenTags. Added ability to use custom fonts in the tag cells.
  • v0.0.5 - Added expected functionality of chosenTags being removed when pressed.

Author

Paul Rolfe, [email protected], @ThePaulRolfe

License

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

Comments
  • Change

    Change "chosen tags" via code

    Hi,

    I want to change the variable "chosenTags" (ex: remove all or add all tags available).

    But, when I setting a new NSMuttableArray, and in sequence, if I try select a new Tag the app's broke.

    The code is like this:

    - (IBAction)addAll:(id)sender {
        [self clearAll:nil];
    
        [_tagPicker setChosenTags:[self.allTags mutableCopy]];
    }
    - (IBAction)clearAll:(id)sender {
        self.preChosenTags = @[];
        [_tagPicker setChosenTags:[self.preChosenTags mutableCopy]];
    }
    

    I have to do something else?

    Thanks.

    opened by gabrieltva 3
  • Can't find some properties ..

    Can't find some properties ..

    First of all, thanks for this amazing tool! There are thing that I can't find. Firstly, i can't call textField in my controller for edit placeholder or another properties. Secondly, i can't find some property to stop removing tags by double tapping. And can I change only first tag border,background and text color? I found textfield in the library, and change placeholder, but I thing there should be properly way to do it. Pleas, help with it.

    opened by ZalyalovIldar 3
  • Need dynamic search input text hashtag

    Need dynamic search input text hashtag

    Hi,

    You did great job!

    Here what I need, My design look like this and search suggestion from API so it's dynamic based on textfield text. So I edit source code like this

    -(void)addDynamicTextFromSearch:(NSString *)newString
    {
        [self.chosenTags addObject:newString];
        NSIndexPath *addedPath = [NSIndexPath indexPathForItem:self.chosenTags.count inSection:0];
        [self.chosenTagCollectionView insertItemsAtIndexPaths:@[addedPath]];
        [self.chosenTagCollectionView scrollToItemAtIndexPath:addedPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontally animated:YES];
    }
    

    And I got output like this two placeholder when I tap text from my API output. screen shot 2016-04-12 at 8 43 55 pm

    When I scroll that get correct text(horizontally) which I selected, with extra placeholder textView like this screen shot 2016-04-12 at 8 44 27 pm

    At init method I didn't give any allTag to search when user type. I want insert dynamic text based on my API search text.

    self.tagPicker = [[PARTagPickerViewController alloc] init];
    
        self.tagPicker.view.frame = CGRectMake(0, 0, self.tagPickerView.frame.size.width, self.tagPickerView.frame.size.height); // self.tagPickerView.frame;   //78 is the fully expanded height.
    
        [self.tagPicker.view.layer setCornerRadius:CGRectGetHeight(self.tagPicker.view.frame) / 2];
    
        self.tagPicker.view.layer.borderColor = [UIColor KSCloudyBlueColor].CGColor;
    
        self.tagPicker.view.layer.borderWidth = 1.0;
    
        self.tagPicker.view.backgroundColor = [UIColor clearColor];
    
        self.tagPicker.view.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    
        self.tagPicker.delegate = self;
    
        self.tagPicker.allTags = @[];
    
        //optionally allow new tags to be made
        self.tagPicker.allowsNewTags = YES;
    
    
        [self addChildViewController:self.tagPicker];
    
        [self.tagPickerView addSubview:self.tagPicker.view];
    

    My init code

    Is this possible?

    Thanks in advance :)

    opened by mathiarasan24 2
  • Feature Request (From Ildar)

    Feature Request (From Ildar)

    Good Day! I working with your library and wanna show tagPicker in each cell in my TableView ('cause it scrollable and easy to use), BUT there a some problem: every time to ends of tags adding textField (I see that it's for creating new tags, but when I show tags in tableView i don't want create some new tags there, so could you help me and explain where i can change some pice of code to create TagPicker without textField in the end.

    With respect, …

    P.S. I tried to do it by my self, but in collectionView_cellForItemAtIndexPath throw exception when I tried to delete, or edit place when you add textField.

    enhancement 
    opened by paulrolfe 2
  • Use in UITableViewCell

    Use in UITableViewCell

    Hello, I need to use this in a custom UITableViewCell. I've tried putting the adding the picker.view as a subview to the cell and setting the delegate to the UITableViewController, but the picker is just blank with the background color showing. Any advice?

    let tagPicker = PARTagPickerViewController()
    tagPicker.view.backgroundColor = UIColor.whiteColor()
    tagPicker.view.frame = CGRect(x: 0, y: 0, width: CGRectGetWidth(cell.bounds), height: COLLECTION_VIEW_HEIGHT)
    tagPicker.view.autoresizingMask = UIViewAutoresizing.FlexibleWidth
    tagPicker.delegate = self
    tagPicker.allTags = ["hurfi", "durfi"]
    tagPicker.allowsNewTags = true
    tagPicker.chosenTags = NSMutableArray(array: queries)
    tagPicker.visibilityState = .TopAndBottom
    
    self.addChildViewController(tagPicker)
    cell.paddingView.addSubview(tagPicker.view)
    
    opened by lukkigi 2
  • Integration from cocoapods don't work out of the box

    Integration from cocoapods don't work out of the box

    You still have to search for the nibs and include them in the project, must be done programatically or included in pod bundle.

    Thanks for your great work :)

    opened by ousabasa 2
  • A code snippet to guide the usage in swift

    A code snippet to guide the usage in swift

    I think for someone who is starting out in iOS, it's little confusing or complicated to implement the instructions to use the library. I thought a simple code snippet would be helpful. Let me know your thoughts.

    Thanks!

    opened by sandeepjoshi1910 1
  • Can't order tags

    Can't order tags

    Whatever the order the tags are in, it seems that they will always be in reverse alphabetical order when they show up.

    Is there a workaround that?

    Thanks, Dalia

    opened by daliadanila 1
  • crash after deleting tags with the same name

    crash after deleting tags with the same name

    implemented it in swift 2.3, it crashes wenn you insert two tags with the same text and try to delete one.

    Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in section 0. The number of items contained in an existing section after the update (2) must be equal to the number of items contained in that section before the update (4), plus or minus the number of items inserted or deleted from that section (0 inserted, 1 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).

    opened by viktorwillmann 1
  • Index 0 beyond bounds for empty array

    Index 0 beyond bounds for empty array

    This bug is caused when the the textfieldEnabled is set to false and occurs a touch into de textField, the method - (void)removeChosenTagFromIndexPath:(NSIndexPath *)indexPath is throwing the error: index 0 beyond bounds for empty array.

    Thats because the array chosenTags is not set.

    i made a pull request with an hotfix, but i don't know if is the better approach.

    opened by ostanik 1
  • Adding icon/fontimage with tag

    Adding icon/fontimage with tag

    Hi, Thanks for the nice lib, Does this lib has ability to add a custom icon of "x" or "+" on right or left side of the tag?

    or any way to achieve the same in this ?

    opened by eshajari 0
  • adding the same value twice from alltags causes a crash

    adding the same value twice from alltags causes a crash

    If you try to add the same Tag from your proposed alltags to your chosenTags twice right after the first one was added, you get a crash. This can happen if you fill your proposed tags from your backend.

    In my case if I type "su" my backend will give me "sun" and "sunny" back. if i add the tag "sun" and keep typing "sun" i get again "sun" and "sunny", where i can add Sun again to my chosenTags.

    *** Assertion failure in -[UICollectionView _endItemAnimationsWithInvalidationContext:tentativelyForReordering:animator:], 
    
    /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit/UIKit-3600.5.2/UICollectionView.m:5585
    
    2016-11-30 00:09:09.964160 Inline App[2760:770432] *** Terminating app due to uncaught 
    
    exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of items in 
    
    section 0.  The number of items contained in an existing section after the update (2) must be equal to 
    
    the number of items contained in that section before the update (2), plus or minus the number of items 
    
    inserted or deleted from that section (1 inserted, 0 deleted) and plus or minus the number of items 
    
    moved into or out of that section (0 moved in, 0 moved out).'
    
    opened by viktorwillmann 3
  • getting the search string / fire a method everytime the search string is manipulated

    getting the search string / fire a method everytime the search string is manipulated

    the shown allTags are changed whenever the search string is changed. Now i want to use the search string to load proposed tags from my backend, ever time it is manipulated.

    is the search string accessible? is there a way to fire a function whenever it is manipulated?

    enhancement help wanted 
    opened by viktorwillmann 2
Owner
Paul Rolfe
Paul Rolfe
TagsGridView: A simple view for your tags

TagsGridView: A simple view for your tags. Requirements Installation Contents License Support Credits Requirements iOS 14, macOS 10.15 Swift 5.5 Xcode

Alex 5 Nov 4, 2021
Highly customizable iOS tags view [input, edit, dynamic, tag, token, field, NSTokenField]

RKTagsView Highly customizable iOS tags view (like NSTokenField). Supports horizontal and vertical direction, editing, multiple selection, Auto Layout

Roman Kulesha 450 Oct 2, 2022
UIScrollView subclass that allows to add a list of highly customizable tags.

UIScrollView subclass that allows to add a list of highly customizable tags. You can customize colors, border radius, and the tail of the tag. Tags ca

Andrea Mazzini 765 Nov 19, 2022
An iOS text field that represents tags, hashtags, tokens in general.

WSTagsField An iOS text field that represents tags, hashtags, tokens in general. Usage let tagsField = WSTagsField() tagsField.layoutMargins = UIEdgeI

Whitesmith 1.2k Jan 9, 2023
Simple and highly customizable iOS tag list view, in Swift.

TagListView Simple and highly customizable iOS tag list view, in Swift. Supports Storyboard, Auto Layout, and @IBDesignable. Usage The most convenient

Ela Workshop 2.5k Dec 28, 2022
Simple and highly customizable iOS tag list view, in Swift.

TagListView Simple and highly customizable iOS tag list view, in Swift. Supports Storyboard, Auto Layout, and @IBDesignable. Usage The most convenient

Ela Workshop 2.5k Dec 31, 2022
🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!

YNSearch + Realm Support Updates See CHANGELOG for details Intoduction ?? Awesome search view, written in Swift 5.0, appears search view like Pinteres

Kyle Yi 1.2k Dec 17, 2022
This plugin defines a global navigator.camera object, which provides an API for taking pictures and for choosing images from the system's image library.

title description Camera Take pictures with the device camera. AppVeyor Travis CI cordova-plugin-camera This plugin defines a global navigator.camera

null 0 Nov 2, 2021
slider view for choosing categories. add any UIView type as category item view. Fully customisable

CategorySliderView Horizontal or vertical slider view for choosing categories. Add any UIView type as category item view. Fully customisable Demo Inst

Cem Olcay 353 Nov 6, 2022
Unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application.

Tumblr SDK for iOS An unopinionated and flexible library for easily integrating Tumblr data into your iOS or OS X application. The library uses ARC re

Tumblr 420 Dec 8, 2022
An alternative Tumblr client for iOS

BlogQuest An alternative Tumblr client for iOS. First prize winner, 2014 Tumblr Hack Day. Kinda like Facebook Paper but for Tumblr. We meant to finish

Bryan Irace 14 Feb 10, 2022
WPArticleView - SwiftUI View for Wordpress JSON API

WPArticleView Installation ... dependencies: [ .package(url: "https://github

Aleksei Ilin 2 Oct 20, 2022
Provides an iOS view controller allowing a user to draw their signature with their finger in a realistic style.

Swift version now available! Mimicking pen-on-paper signatures with a touch screen presents a difficult set of challenges. The rate touch events are e

Uber Open Source 1.3k Jan 6, 2023
Joseph Miller 0 Jan 7, 2022
Useful for showing text or custom view tags in a vertical or horizontal scrollable view and support Autolayout at the same time

Useful for showing text or custom view tags in a vertical or horizontal scrollable view and support Autolayout at the same time. It is highly customizable that most features of the text tag can be configured.

zekunyan 1.8k Dec 30, 2022
Circle Loading View Pod

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

null 0 Nov 24, 2021
WordPress for iOS - Official repository

WordPress for iOS Build Instructions Please refer to the sections below for more detailed information. The instructions assume the work is performed f

WordPress Mobile 3.4k Jan 9, 2023
A Wordpress Article Loader for SwiftUI.

SwiftUIWPArticleLoader Hello to WPArticleLoader! With the WPArticleLoader, you can easily load Articles from your WordPress Website. How to use? The u

Torben Köhler 10 Sep 27, 2022
SwiftUIWordpressClient - An iOS application for any WordPress website

SwiftUIWordpressClient SwiftUIWordpressClient is an iOS application for any Word

Liubov Ilina 3 Sep 27, 2022
Simple example for the coordinator design pattern and using th Xcoordinator pod

Cordinator-Pattern-Sample This an Example and base for the coordinator design pattern using the XCoordinator pod ?? XCoordinator is a navigation frame

Ali Fayed 3 Sep 13, 2022