0

As the question states, is it possible to disable userInteracion within a UICollectionViewCell?

I know the code is to disable the view would be: self.view.userInteractionEnabled = NO; in the .m file.

I have a button inside a Cell and I'm wondering if during the action of this button I could disable the entire View until the action is done (action: saving an image).

Any thoughts would be appreciated!

Note: Cell has its own class. Inside the button with its action method.

adriennemhenry
  • 133
  • 1
  • 3
  • 17

2 Answers2

1

Base on your description, the saving action is asynchronous, so you can insert self.view.userInteractionEnable = NO to the top selector of the button's touch event. and resume it after the saving.

- (void)onButtonClick:(UIButton *)button{
    //self.view.userInteractionEnable = NO;
    self.userInteractionEnable = NO;
    /* start saving the image  */

}
//here maybe the callback for your saving
- (void)savingImageFinished{
    //self.view.userInteractionEnable = YES;
    self.userInteractionEnable = YES;
}
Siverchen
  • 379
  • 2
  • 16
  • Yea, I tried this but it throws an error: "Property 'view' not found on object of type..." since my cell has it's own class and the button is inside it, as well as the action method. – adriennemhenry May 22 '14 at 04:30
  • 1
    @adriennemhenry just as your title said, you want to disable the view in the cell, so whether the "view" is a property of your cell? – Siverchen May 22 '14 at 04:33
  • Perfect! Thanks, that helped.. setting the property I mean. – adriennemhenry May 22 '14 at 04:39
0

You can use a block with a completion handler for the button action. Disable the userInteraction within the block code and in the completion handler add self.view.userInteractionEnabled = YES to reenable it.

Nikos M.
  • 13,685
  • 4
  • 47
  • 61
  • My cell has its own class so if I try implementing this in its .m file it throws an error: " Property 'view' not found on object of type..." – adriennemhenry May 22 '14 at 04:28
  • If the view that contains the collection view is the owner of the cell class you can put the action for the cell buttons in the .m of the viewController – Nikos M. May 22 '14 at 04:30
  • Yes, but in this case I need for it to be inside the cell class. Is there any way to do it from inside the cell class? – adriennemhenry May 22 '14 at 04:34
  • @adriennemhenry did tried `self.userInteractionEnable` to `YES` or `NO` instead of `self.view.userInteractionEnabled`? – Akhilrajtr May 22 '14 at 04:36
  • @Akhilrajtr Nah it didn't but figured it out. Setting the property of the view inside the cell class helped. – adriennemhenry May 22 '14 at 04:41