What's the trick to pass an event to the next responder in the responder chain?

前端 未结 8 987
悲&欢浪女
悲&欢浪女 2020-12-05 14:44

Apple is really funny. I mean, they say that this works:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    UITouch* touch = [touches any         


        
相关标签:
8条回答
  • 2020-12-05 15:39

    Today I found a better method to fix this or the question like this.

    In yours UITableViewCell,you can add a delegate to listen the touch event, like this:

    @protocol imageViewTouchDelegate
    
    -(void)selectedFacialView:(NSInteger)row item:(NSInteger)rowIndex;
    
    @end
    
    @property(nonatomic,assign)id<imageViewTouchDelegate>delegate;
    

    Then in yours UITableViewController:your can done like this:

    @interface pressionTable : UITableViewController<facialViewDelegate>
    

    and in the .m file you can implemate this delegate interface,like:

    -(void)selectedFacialView:(NSInteger)row item:(NSInteger)rowIndex{
    //TO DO WHAT YOU WANT}
    

    NOTE:when you init the cell,you must set the delegate,otherwise the delegate is invalid,you can do like this

    - (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    static NSString *CellIdentifier = @"Cell";
    
    pressionCell *cell = (pressionCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[pressionCell alloc]initWithFrame:CGRectMake(0, 0, 240, 40)];
    }
    
    cell.delegate = self;
    

    }

    PS:I know this DOC is old, but I still add my method to fix the question so when people meet the same problem, they will get help from my answer.

    0 讨论(0)
  • 2020-12-05 15:43

    I know this post is old but i thought id share because I had a similar experience. I fixed it by setting the userInteractionEnabled to NO for the view of the view controller that was automatically created.

    0 讨论(0)
提交回复
热议问题