0

I am working on a project in which I have a category list of items which I display in a UITableView and also I am using a UITextField to show the selected items from UITableView. The problem is that when I select any row only one item is showing in the UITextField but I want to show more than 1 items in UITextField with Delete button by which I can remove the selected item from the TextField. I am sharing the screen-shot of the project idea what I want to implement please help enter image description here enter image description here

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Abhinandan Pratap
  • 2,142
  • 1
  • 18
  • 39
  • [probably duplicate](http://stackoverflow.com/questions/3915737/creating-a-uitextfield-that-works-like-the-ios-mails-to-field) seems to answer what u would like to achieve – Tj3n Oct 27 '15 at 04:44
  • You can check this library : https://github.com/jasarien/JSTokenField or https://github.com/venmo/VENTokenField – Ashish Kakkad Oct 27 '15 at 04:45
  • u need to add uibutton as a subview or u can use uicollectionview for this purpose write any thing on uitextfield and show record in button or uicollectionview cell which should be above of uitextfield. ..Or use uistackview for this purpose – baydi Oct 27 '15 at 04:45

1 Answers1

1

You Can do this way also add text of each row of uitableview in an nsarray and then that array convert into nsstring and then display that string into the textfield.

- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if(tableView == itemTable)
    {

    UITableViewCell *selectedCell = [itemTable cellForRowAtIndexPath:indexPath];
        if([itemArray containsObject:selectedCell.textLabel.text])
        {
            [itemArray removeObject:selectedCell.textLabel.text];

        }
        else
        {

            [itemArray addObject:selectedCell.textLabel.text];
            NSLog(@"%@", selectedCell.textLabel.text);

        }
        NSString *str = [itemArray componentsJoinedByString:@","];
        elementsField.text = str;
        NSLog(@"%@",str);
       [itemTable deselectRowAtIndexPath:indexPath animated:YES];
        elementsView.hidden = YES;
    }
}