2010-02-05 51 views
0

我想知道我怎麼會停止我的sublassØUIScrollView的工作不正常:的UIScrollView潤色覆蓋

- (void) touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view { 

    if ([touches count] == 2) { 

     [super touchesShouldBegin:[touches anyObject] withEvent:event inContentView:view]; 
    } 
    else { 
     //How do I stop it completely from using one touch? 
    } 

} 

我只希望當它有2個觸摸一切我想做什麼就採取行動。甚至更好,如果你能告訴我如何通過觸摸else語句到一個UIView:

UntitledViewController.otherView 

如果你能告訴我怎麼做,那麼我會很高興。

回答

0

您正在重寫的方法實際上會返回一個BOOL值,該值告訴scrollView處理觸摸或不觸摸。因此,在實際執行應該更像:

- (BOOL) touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view { 
    if ([touches count] == 2) { 
     return YES; 
    } 
    else { 
     return NO; 
    } 
} 

現在,當它不處理這些觸摸,它會自動將其傳遞到下一個響應者,這應該是你的UntitledViewController.otherView