V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
iOS 开发实用技术导航
NSHipster 中文版
http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
http://www.cocos2d-iphone.org/
CocoaPods
http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
http://code.google.com/mobile/analytics/
WWDC
https://developer.apple.com/wwdc/
Design Guides and Resources
https://developer.apple.com/design/
Transcripts of WWDC sessions
http://asciiwwdc.com
Cocoa with Love
http://cocoawithlove.com/
Cocoa Dev Central
http://cocoadevcentral.com/
NSHipster
http://nshipster.com/
Style Guides
Google Objective-C Style Guide
NYTimes Objective-C Style Guide
Useful Tools and Services
Charles Web Debugging Proxy
Smore
xujialiang
V2EX  ›  iDev

唉,一个 IOS 问题求助,实在是没办法了。。要失眠了~~~~~

  •  
  •   xujialiang ·
    xujialiang · Apr 24, 2014 · 6378 views
    This topic created in 4387 days ago, the information mentioned may be changed or developed.
    我模仿微信的按住说话,Button在屏幕底部,我按住button,没有触发touchdown事件。我手指离开时,同时触发touchdown和touchup事件。。
    但是 如果我把button 放在屏幕上方一点,比如屏幕中间,就一切正常,按下直接能触发touchdown事件。为什么?
    Supplement 1  ·  Apr 25, 2014
    感谢各位,我发现问题根源了,uinavigationcontroller自己有interactionpopgesture,如果按钮在底部,恰巧又是在屏幕左边,那么按钮的touchdown事件会失效,也不算失效,就是手指当下去不会立即触发,要手指动一动。在我禁用了interactionpopgesture后,按钮的事件正常了,但是腾讯是如何处理的呢?我看到微信的左划返回前一页还是正常的
    Supplement 2  ·  Apr 25, 2014
    经过大家坚持不懈的努力,我终于找到解决方案了。
    这是我测试的项目http://xujialiang.net/TestGesture.zip
    - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{
    if ([touch.view isKindOfClass:[XJLButtonPress class]]) {
    [self.btnbutton sendActionsForControlEvents:UIControlEventTouchDown];
    return NO;
    }
    return YES;
    }
    这是主要的代码 哈哈哈
    25 replies    1970-01-01 08:00:00 +08:00
    Cwind
        1
    Cwind  
       Apr 24, 2014   ❤️ 1
    试下禁用Control Center后是否还会有这个问题?
    txx
        2
    txx  
       Apr 24, 2014   ❤️ 1
    為什麼不用Gesture 而是用 UIControlEvent 呢...
    順路說...iOS 謝謝...
    alexrezit
        3
    alexrezit  
       Apr 24, 2014   ❤️ 1
    @txx
    其實這種情況用 control event 寫起來更簡單, 雖然我們的項目裏我用的也是 gesture recognizer. = =
    而且樓主的問題應該是自己哪兒寫挫了.
    txx
        4
    txx  
       Apr 24, 2014   ❤️ 1
    @alexrezit
    1、你趕緊給我睡覺去...
    2、我懷疑是樓主的frame有問題....推薦用reveal 看看
    Cee
        5
    Cee  
       Apr 24, 2014
    ls秀恩爱= =
    txx
        6
    txx  
       Apr 25, 2014
    @Cee 這傢伙身體太可怕....太容易掛掉了,不看這點不行。

    順便吐槽樓主一句,這也好意思說自己失眠了。我剛解決了一個bug想回來看看樓主有什麼新進展可以討論一下的..
    結果發現是nothing啊...
    Cee
        7
    Cee  
       Apr 25, 2014   ❤️ 1
    @txx 身体是革命的本钱><
    @alexrezit 每天都得⑨点去滚床哦

    自己还在写做作业TAT 冒个泡
    dorentus
        8
    dorentus  
       Apr 25, 2014 via iPad
    附议楼上,这也叫失眠?
    alexrezit
        9
    alexrezit  
       Apr 25, 2014
    @txx
    @Cee
    其實是睡醒了一覺起來冒個泡吃點東西又回去繼續睡的... = =
    alexrezit
        10
    alexrezit  
       Apr 25, 2014
    @txx
    只是 frame 的話 simulator 自帶 layer 著色功能的, 看 responder chain 才用得著 Reveal 吧.
    xujialiang
        11
    xujialiang  
    OP
       Apr 25, 2014 via iPhone
    感谢各位楼上,我发现问题根源了,uinavigationcontroller自己有interactionpopgesture,如果按钮在底部,恰巧又是在屏幕左边,那么按钮的touchdown事件会失效,也不算失效,就是手指当下去不会立即触发,要手指动一动。
    hoogle
        13
    hoogle  
       Apr 25, 2014   ❤️ 1
    interactionpopgesture的问题,实现UIGestureDelegate的shouldBeRequiredToFailByGestureRecognizer。
    railgun
        14
    railgun  
       Apr 25, 2014
    怎么搞iOS开发的都是死宅……
    txx
        15
    txx  
       Apr 25, 2014
    @railgun 人家才不是搞iOS開發的呢!
    Hysteria
        16
    Hysteria  
       Apr 25, 2014
    我还以为是frame问题。
    hongri
        17
    hongri  
       Apr 25, 2014
    austinchou0126
        18
    austinchou0126  
       Apr 25, 2014
    我只是进来膜拜一下楼上各位的。。。
    robinshi2010
        19
    robinshi2010  
       Apr 25, 2014
    通常都是冲突了。当初也掉到这个坑里过。
    alexrezit
        20
    alexrezit  
       Apr 25, 2014
    @txx
    承認自己是死宅了嗯.
    xx314327475
        21
    xx314327475  
       Apr 25, 2014
    我为什么点了这个帖子.....额...
    Jellyan
        22
    Jellyan  
       Apr 25, 2014
    楼主好无辜,完全被忽略了
    NUT
        23
    NUT  
       Apr 25, 2014   ❤️ 1
    可以自己实现一个button。
    思路:继承一个UIview,当触摸点在这个view上时,触发按下的事件。如果触摸点划出这个范围则响应不是没在触摸区域的事件。
    主要玩
    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
    - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
    这三个方法。

    AwesomeMenu这个库有具体的实现。看了就明白。
    txx
        24
    txx  
       Apr 25, 2014   ❤️ 1
    @NUT 樓主發現問題是和iOS7的滑動手勢衝突了。

    所以關注點應該是 把滑動返回的 delegate 設到當前頁面 然後處理手勢區域。

    不過我還是更推崇用 Gesture,然後iOS 7 多了一些手勢有關的delegate,能更好的處理衝突。
    xujialiang
        25
    xujialiang  
    OP
       Apr 25, 2014
    在上班。。。。回去再看看具体怎么解决,前面试了下interactiongesture的代理,手指碰上屏幕就有事件。下面还要判断 是否点在button上。
    @NUT 自己写个button太麻烦了,如果好多页面有自定义的button,那要写好多呢。。。。。

    我想让navigationcontroller的左滑识别区域不包含屏幕底部,高度大概44.
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   5627 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 95ms · UTC 01:35 · PVG 09:35 · LAX 18:35 · JFK 21:35
    ♥ Do have faith in what you're doing.