Git Product home page Git Product logo

aktagsinputview's People

Contributors

kas-kad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

aktagsinputview's Issues

If `selectedTags` is empty while initializing, the lookup list is empty too.

- (void)setTagsInputView:(AKTagsInputView *)tagsInputView
{
    _tagsInputView = tagsInputView;

    _tagsInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    _tagsInputView.lookupTags = @[@"ios", @"iphone", @"objective-c", @"development", @"cocoa", @"xcode", @"icloud"];
    _tagsInputView.selectedTags = [NSMutableArray array];// this will cause the bug
    _tagsInputView.enableTagsLookup = YES;
}

Can't set Lookup Tags again

I am initializing my AKTagsInputView as

// cats is a NSArray containing lookup tags
aktv = [[AKTagsInputView alloc] initWithFrame:frame];
aktv.allowDeleteTags = YES;
aktv.enableTagsLookup = YES;
aktv.lookupTags = cats;
[self.view addSubview:aktv];

The above code works fine. But after sometime I get new tags and I am calling
aktv.lookupTags = newCats;

Now I expect the newCats to be shown as lookup tags. But that does not work. The only way I can make it to work is

[aktv removeFromSuperView];
aktv = [[AKTagsInputView alloc] initWithFrame:frame];
aktv.allowDeleteTags = YES;
aktv.enableTagsLookup = YES;
aktv.lookupTags = newTags;
[self.view addSubview:aktv];

if there was no selectedTags, typing does not bring lookup tags

how to reproduce:

  • on initialization
    _tagsInputView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    _tagsInputView.lookupTags = @[@"ios", @"iphone", @"objective-c", @"development", @"cocoa", @"xcode", @"icloud"];
    _tagsInputView.selectedTags = [NSMutableArray array];
    _tagsInputView.enableTagsLookup = YES;
  • run and make the text field the first responder

Customization options

Please add the posibility to customize the colors of the tags and other elements, because it is an awesome library and works pretty well, but we are not able to customize it.

Thanks!

Tag lookup dies on big data sources

if there is 9288 or more items in lookup table it becomes very slow. Better approach is using NSFetchedResultsController as a DataSource for collectionView.

After adding tap gesture I can not remove tags by clicking x button

  • added TapGesture to ViewController's view
  • added action for tap which should drop the keyboard
@interface AKViewController ()
{
    AKTagsInputView *_tagsInputView;
    UITapGestureRecognizer *_tapGesture;
}
@end

and implementation

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = WK_COLOR(200, 200, 200, 1);
    [self.view addSubview:[self createLabel]];
    [self.view addSubview:[self createTagsInputView]];
    [self.view addSubview:[self createButton]];
    [self.view addSubview:[self clearButton]];

    _tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(actionTap:)];
    [self.view addGestureRecognizer:_tapGesture];
    [_tapGesture setNumberOfTapsRequired:1];
}
- (IBAction)tapAction:(id)sender
{
    [self.tagsInputView resignFirstResponder];
}

BUG: I can not delete selected tags any more

NSInternalInconsistencyException when attempting to add tags in example

Attempting to add tags in example results in an NSInternalInconsistencyException:

AKTagsInputViewExample[54660:22954455] *** 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 (6) must be equal to the number of items contained in that section before the update (7), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
*** First throw call stack:
(
0 CoreFoundation 0x000000010516c3f5 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000104e05bb7 objc_exception_throw + 45
2 CoreFoundation 0x000000010516c25a +[NSException raise:format:arguments:] + 106
3 Foundation 0x0000000104a2328f -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195
4 UIKit 0x0000000103cfdfb7 -[UICollectionView _endItemAnimations] + 12835
5 UIKit 0x0000000103d031f9 -[UICollectionView performBatchUpdates:completion:] + 390
6 AKTagsInputViewExample 0x00000001033d15c4 -[AKTagsLookup filterLookupWithPredicate:] + 260
7 AKTagsInputViewExample 0x00000001033cc489 -[AKTagsInputView addNewItemWithString:completion:] + 233
8 AKTagsInputViewExample 0x00000001033cbab7 -[AKTagsInputView tagsLookup:didSelectTag:] + 103
9 AKTagsInputViewExample 0x00000001033d18ec -[AKTagsLookup tagsListView:didSelectTag:atIndexPath:] + 236
10 AKTagsInputViewExample 0x00000001033c9180 -[AKTagsListView collectionView:didSelectItemAtIndexPath:] + 320
11 UIKit 0x0000000103d04929 -[UICollectionView

resign first responder does not work properly

  • added TapGesture to ViewController's view
  • added action for tap which should drop the keyboard
- (IBAction)tapAction:(id)sender
{
    [self.tagsInputView resignFirstResponder];
}
  • but:
  • keyboard does not hide

It seems to be working ok if you just tapped [+ ADD] textField and stops working if it disappears.

  • should this [+ ADD] disappear?

iOS 8 Crash - exception 'NSInternalInconsistencyException'

Logs:
AKTagsInputViewExample[49510:1619253] *** Assertion failure in -[UICollectionView _endItemAnimations], /SourceCache/UIKit_Sim/UIKit-3318.16.14/UICollectionView.m:3917
AKTagsInputViewExample[49510:1619253] *** 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 (0) must be equal to the number of items contained in that section before the update (7), plus or minus the number of items inserted or deleted from that section (0 inserted, 0 deleted) and plus or minus the number of items moved into or out of that section (0 moved in, 0 moved out).'
*** First throw call stack:
(
0 CoreFoundation 0x01c67946 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x018f0a97 objc_exception_throw + 44
2 CoreFoundation 0x01c677da +[NSException raise:format:arguments:] + 138
3 Foundation 0x01564810 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
4 UIKit 0x009f5638 -[UICollectionView _endItemAnimations] + 14381
5 UIKit 0x009fb5c8 -[UICollectionView _endUpdates] + 44
6 UIKit 0x009fb77a -[UICollectionView performBatchUpdates:completion:] + 429
7 AKTagsInputViewExample 0x00012a24 -[AKTagsLookup filterLookupWithPredicate:] + 276
8 AKTagsInputViewExample 0x0000d0c5 -[AKTagsInputView textField:shouldChangeCharactersInRange:replacementString:] + 1301
9 UIKit 0x00b195bf -[UITextField keyboardInput:shouldInsertText:isMarkedText:] + 273
10 UIKit 0x00504489 -[UIKeyboardImpl callShouldInsertText:] + 269
11 UIKit 0x0050f818 -[UIKeyboardImpl addInputEvent:executionContext:] + 1010
12 UIKit 0x0050f37c __60-[UIKeyboardImpl addInputString:withFlags:executionContext:]_block_invoke + 53
13 UIKit 0x00b41b08 -[UIKeyboardTaskExecutionContext returnExecutionToParentWithInfo:] + 289
14 UIKit 0x00b419e2 -[UIKeyboardTaskExecutionContext returnExecutionToParent] + 41
15 UIKit 0x0051421b -[UIKeyboardImpl acceptCurrentCandidateIfSelectedWithExecutionContext:] + 250
16 UIKit 0x0050f33f -[UIKeyboardImpl addInputString:withFlags:executionContext:] + 537
17 UIKit 0x0050e184 -[UIKeyboardImpl handleStringInput:withFlags:executionContext:] + 251
18 UIKit 0x0051f2c2 -[UIKeyboardImpl handleKeyWithString:forKeyEvent:executionContext:] + 652
19 UIKit 0x0051e7cb -[UIKeyboardImpl handleKeyEvent:executionContext:] + 181
20 UIKit 0x0051e67f __33-[UIKeyboardImpl handleKeyEvent:]_block_invoke + 51
21 UIKit 0x0051e484 -[UIKeyboardImpl _handleKeyEvent:executionContext:] + 243
22 UIKit 0x006e84f2 -[UIKeyboardLayoutStar completeRetestForTouchUp:timestamp:interval:executionContext:] + 4415
23 UIKit 0x006e689d -[UIKeyboardLayoutStar touchUp:executionContext:] + 174
24 UIKit 0x0052d4c5 __28-[UIKeyboardLayout touchUp:]_block_invoke + 283
25 UIKit 0x00b420a2 -[UIKeyboardTaskQueue continueExecutionOnMainThread] + 404
26 UIKit 0x00b4275f -[UIKeyboardTaskQueue addTask:] + 144
27 UIKit 0x0052d3a2 -[UIKeyboardLayout touchUp:] + 294
28 UIKit 0x0052e0ae -[UIKeyboardLayout touchesEnded:withEvent:] + 539
29 UIKit 0x0031960a -[UIWindow _sendTouchesForEvent:] + 874
30 UIKit 0x0031a0e5 -[UIWindow sendEvent:] + 791
31 UIKit 0x002df549 -[UIApplication sendEvent:] + 242
32 UIKit 0x002ef37e _UIApplicationHandleEventFromQueueEvent + 20690
33 UIKit 0x002c3b19 _UIApplicationHandleEventQueue + 2206
34 CoreFoundation 0x01b8b1df CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 15
35 CoreFoundation 0x01b80ced __CFRunLoopDoSources0 + 253
36 CoreFoundation 0x01b80248 __CFRunLoopRun + 952
37 CoreFoundation 0x01b7fbcb CFRunLoopRunSpecific + 443
38 CoreFoundation 0x01b7f9fb CFRunLoopRunInMode + 123
39 GraphicsServices 0x040bc24f GSEventRunModal + 192
40 GraphicsServices 0x040bc08c GSEventRun + 104
41 UIKit 0x002c78b6 UIApplicationMain + 1526
42 AKTagsInputViewExample 0x00011e0d main + 141
43 libdyld.dylib 0x0223bac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

Deleting tags can leave the cursor unreachable

  1. enter a few tags then start typing a new tag
  2. scroll left so the text goes off-screen
  3. delete a couple of tags but not enough to let the text come back on screen
  4. scroll back to the right
    Then the cursor position is not updated correctly and can be off screen and unreachable (and continuing can then cause a crash).

The solution is it just needs the cursor to be moved left by the width of the deleted tag each time a tag is deleted.

Rob

Simple editing the tags

  1. Enable always the delete button:
    • open file AKTagCell.m
    • delete _deleteButton.enabled = selected; from -(void)setSelected:(BOOL)selected
    • replace _deleteButton.enabled = NO; on _deleteButton.enabled = YES; from -(UIButton *)deleteButton
  2. Add next code to the file AKTagsInputView.m
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    UIAlertView *alertViewChangeTag = [[UIAlertView alloc] init];
    [alertViewChangeTag setDelegate:self];
    [alertViewChangeTag setTitle:@"Edit tag"];
    [alertViewChangeTag addButtonWithTitle:@"Cancel"];
    [alertViewChangeTag addButtonWithTitle:@"OK"];
    [alertViewChangeTag setAlertViewStyle:UIAlertViewStylePlainTextInput];

    AKTagCell* cell = (AKTagCell*)[collectionView cellForItemAtIndexPath:indexPath];
    [[alertViewChangeTag textFieldAtIndex:0] setText:cell.tagName];
    [[alertViewChangeTag textFieldAtIndex:0] setDelegate:self];
    [alertViewChangeTag show];
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSString *newTag = [[alertView textFieldAtIndex:0] text];

    if (buttonIndex == 1 && newTag.length > 0) {
        NSIndexPath* index = [self.collectionView indexPathsForSelectedItems][0];
        [self deleteItemAt:index completion:nil];
        [self addNewItemWithString:newTag completion:nil];
    }
}

Maybe someone deems useful.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.