<small id='LyHzu'></small><noframes id='LyHzu'>

  1. <i id='LyHzu'><tr id='LyHzu'><dt id='LyHzu'><q id='LyHzu'><span id='LyHzu'><b id='LyHzu'><form id='LyHzu'><ins id='LyHzu'></ins><ul id='LyHzu'></ul><sub id='LyHzu'></sub></form><legend id='LyHzu'></legend><bdo id='LyHzu'><pre id='LyHzu'><center id='LyHzu'></center></pre></bdo></b><th id='LyHzu'></th></span></q></dt></tr></i><div id='LyHzu'><tfoot id='LyHzu'></tfoot><dl id='LyHzu'><fieldset id='LyHzu'></fieldset></dl></div>

    <legend id='LyHzu'><style id='LyHzu'><dir id='LyHzu'><q id='LyHzu'></q></dir></style></legend>
      <bdo id='LyHzu'></bdo><ul id='LyHzu'></ul>

      <tfoot id='LyHzu'></tfoot>

      如何将滑动手势添加到 UITableView 单元格?

      时间:2023-05-31

        <tfoot id='WX1y6'></tfoot>
        <i id='WX1y6'><tr id='WX1y6'><dt id='WX1y6'><q id='WX1y6'><span id='WX1y6'><b id='WX1y6'><form id='WX1y6'><ins id='WX1y6'></ins><ul id='WX1y6'></ul><sub id='WX1y6'></sub></form><legend id='WX1y6'></legend><bdo id='WX1y6'><pre id='WX1y6'><center id='WX1y6'></center></pre></bdo></b><th id='WX1y6'></th></span></q></dt></tr></i><div id='WX1y6'><tfoot id='WX1y6'></tfoot><dl id='WX1y6'><fieldset id='WX1y6'></fieldset></dl></div>

        <small id='WX1y6'></small><noframes id='WX1y6'>

          <tbody id='WX1y6'></tbody>
              <legend id='WX1y6'><style id='WX1y6'><dir id='WX1y6'><q id='WX1y6'></q></dir></style></legend>
                <bdo id='WX1y6'></bdo><ul id='WX1y6'></ul>
                本文介绍了如何将滑动手势添加到 UITableView 单元格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我在 cellForRowAtIndexPath

                中添加了这段代码

                UISwipeGestureRecognizer *gestureR = [[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(handleSwipeFrom:)];[gestureR setDirection:UISwipeGestureRecognizerDirectionRight];//|UISwipeGestureRecognizerDirectionRight)];[单元格 addGestureRecognizer:gestureR];

                它工作正常.但我想要 UISwipeGestureRecognizerDirectionLeft 所以像这样添加

                [gestureR setDirection:UISwipeGestureRecognizerDirectionLeft|UISwipeGestureRecognizerDirectionRight)];

                当我检查方向和状态时,我总是得到 3 = 3

                - (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {NSLog(@"%d = %d",recognizer.direction,recognizer.state);}

                如果我只应用一个手势,它就可以正常工作.我试图一个一个地添加两个手势.但它只会响应一个手势.

                如何添加第二个手势.我直接将一个手势添加到 TableView 另一个手势到单元格,但现在使用.

                解决方案

                试试这个

                <上一页>UISwipeGestureRecognizer* 手势R;手势R = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)] autorelease];手势R.direction = UISwipeGestureRecognizerDirectionLeft;[查看 addGestureRecognizer:gestureR];手势R = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)] autorelease];手势R.direction = UISwipeGestureRecognizerDirectionRight;//默认[查看 addGestureRecognizer:gestureR];

                如果您想处理左右滑动的不同功能,只需更改选择器即可.

                I added this code in cellForRowAtIndexPath

                UISwipeGestureRecognizer *gestureR = [[UISwipeGestureRecognizer alloc]
                                                             initWithTarget:self action:@selector(handleSwipeFrom:)];
                        [gestureR setDirection:UISwipeGestureRecognizerDirectionRight];//|UISwipeGestureRecognizerDirectionRight)];
                        [cell addGestureRecognizer:gestureR];
                

                it works fine. But I want UISwipeGestureRecognizerDirectionLeft so Added like this

                [gestureR setDirection:UISwipeGestureRecognizerDirectionLeft|UISwipeGestureRecognizerDirectionRight)];
                

                When I check with direction and state I am always getting 3 = 3

                - (void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {    
                
                    NSLog(@"%d = %d",recognizer.direction,recognizer.state);
                }
                

                if I apply only one Gesture it works fine. I tried to add two gestures one by one. but it will responding for only one gesture.

                How to add second gestures. I added directly to one gesture to TableView another one to cell but now use.

                解决方案

                Try this

                UISwipeGestureRecognizer* gestureR;
                gestureR = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)] autorelease];
                gestureR.direction = UISwipeGestureRecognizerDirectionLeft;
                [view addGestureRecognizer:gestureR];
                
                gestureR = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom)] autorelease];
                gestureR.direction = UISwipeGestureRecognizerDirectionRight; // default
                [view addGestureRecognizer:gestureR];
                

                If you want to handle different functionalities on left and right swipes, just change the selectors.

                这篇关于如何将滑动手势添加到 UITableView 单元格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:以编程方式添加时模糊 UILabel 下一篇:iOS 5 有垃圾收集吗?

                相关文章

                最新文章

              • <legend id='7xolV'><style id='7xolV'><dir id='7xolV'><q id='7xolV'></q></dir></style></legend>

                • <bdo id='7xolV'></bdo><ul id='7xolV'></ul>

                <tfoot id='7xolV'></tfoot>
                  <i id='7xolV'><tr id='7xolV'><dt id='7xolV'><q id='7xolV'><span id='7xolV'><b id='7xolV'><form id='7xolV'><ins id='7xolV'></ins><ul id='7xolV'></ul><sub id='7xolV'></sub></form><legend id='7xolV'></legend><bdo id='7xolV'><pre id='7xolV'><center id='7xolV'></center></pre></bdo></b><th id='7xolV'></th></span></q></dt></tr></i><div id='7xolV'><tfoot id='7xolV'></tfoot><dl id='7xolV'><fieldset id='7xolV'></fieldset></dl></div>

                1. <small id='7xolV'></small><noframes id='7xolV'>