UA-17470720-3

Jump to content


Photo
- - - - -

SCTextFieldCell with accessoryView not tappable


  • Please log in to reply
5 replies to this topic

#1 Brendan Duddridge

Brendan Duddridge

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 170 posts
Reputation: 7
Good

Posted 01 February 2016 - 08:00 PM

Hey Tarek,

 

I have an SCTextFieldCell with an accessoryView. It's just a UIImageView.

 

I want an action to be performed when I tap on the accessoryView. However, the text field keeps getting focus when I try and it won't allow me to tap on the accessoryView.

 

I've implemented cellActions.accessoryButtonTapped, but it has no effect.

 

The only way I've ben able to get it to work is to implement cellActions.didSelect, but that's the wrong behaviour because I don't want my action to be performed by tapping on the cell itself, just the accessoryView.

 

Any ideas?

 

Thanks!

 

Brendan


Edited by Brendan Duddridge, 01 February 2016 - 08:00 PM.


#2 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 01 February 2016 - 09:09 PM

Hi Brendan,

 

I've added the following code to our bundled TasksApp sample, and everything seems to be working as expected. The code adds an accessory button to the task 'name' SCTextFieldCell. Are you able to replicate this in your app?

 

    SCDataDefinition *taskDef = [self dataDefinitionWithIBName:@"Task"];
    
    SCPropertyDefinition *namePDef = [taskDef propertyDefinitionWithName:@"name"];
    namePDef.cellActions.willConfigure = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
    {
        cell.accessoryType = UITableViewCellAccessoryDetailButton;
    };
    namePDef.cellActions.accessoryButtonTapped = ^(SCTableViewCell *cell, NSIndexPath *indexPath)
    {
        NSLog(@"Accessory button tapped!");
    };


#3 Brendan Duddridge

Brendan Duddridge

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 170 posts
Reputation: 7
Good

Posted 01 February 2016 - 09:53 PM

Hi Tarek,

 

Yes, it works with the accessoryType property as you have there. Just not with the accessoryView property.

 

textCell.accessoryView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"onepassword-button"]];

 
I want it to show the 1Password button icon next to a username text field. So that's why I'm using accessoryView instead of accessoryType. accessoryType just gives me the ( i ) button.


#4 Brendan Duddridge

Brendan Duddridge

    Advanced Member

  • STV 5.0 Pro
  • PipPipPipPipPip
  • 170 posts
Reputation: 7
Good

Posted 01 February 2016 - 09:59 PM

Oh crap.  I have to add a UIButton there instead of a UIImageView. I tried that before and it didn't work. I must have done something wrong.

 

Sorry for taking up your time. My mistake.

 

Thanks,

 

Brendan



#5 ozie

ozie

    ¯\_(ツ)_/¯

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 526 posts
  • LocationAustralia
Reputation: 169
Popular

Posted 01 February 2016 - 10:18 PM

as a note, you can add a gesture to the image view to controls taps etc.. but also by default UIImageView has userInteractionEnabled as False, which is why the cell would receive any touch events etc this would need to be set to True for it to receive touch events


Edited by ozie, 01 February 2016 - 10:19 PM.

  • Tarek likes this

P.S. I hate Swift.. don't talk Swift.. Too old school to learn yet another programming language.


#6 Tarek

Tarek

    Forum Admin

  • Administrators
  • 3670 posts
Reputation: 452
Popular

Posted 02 February 2016 - 05:40 AM

No worries Brendan.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users