Giter Site home page Giter Site logo

Question - How to set a component's controller as a delegate for a gesture created using view attributes CKComponentPanGestureAttribute about componentkit HOT 3 CLOSED

facebook avatar facebook commented on April 25, 2024
Question - How to set a component's controller as a delegate for a gesture created using view attributes CKComponentPanGestureAttribute

from componentkit.

Comments (3)

kastiglione avatar kastiglione commented on April 25, 2024

Some might consider this to be too much "magic", but perhaps when the component controller implements UIGestureRecognizer, the functions provided by CKComponentGestureActions.h could automatically assign the controller as the delegate.

For now though, I'm not sure if there's a better alternative besides ditching CKComponentPanGestureAttribute, and instead handling the construction and delegate assignment of the gesture recognizer inside a component controller.

- (void)componentDidAcquireView
{
  [super componentDidAcquireView];
  _panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(didPan:gesture:)];
  _panRecognizer.delegate = self;
  [self.view addGestureRecognizer:_panRecognizer];
}

- (void)componentWillRelinquishView
{
  [super componentWillRelinquishView];
  [self.view removeGestureRecognizer:_panRecognizer];
}

from componentkit.

darknoon avatar darknoon commented on April 25, 2024

You should need to do nothing to make this work.

While the controller isn't the delegate of the gesture, it is on the responder chain for the gesture. So, you should just implement -didPan:gesture: in your controller and boom.

Re-open the issue if you still have questions.

from componentkit.

 avatar commented on April 25, 2024

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

from componentkit.

Related Issues (20)

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.