2014-03-13 25 views
1

該應用程序包含內容視圖和滑動菜單視圖。滑動菜單是UITableView,它是內容視圖的一部分。在滑動菜單中是UISlider。我添加了touchUpInsidetouchUpOutside動作的目標。當我拖動滑塊並緩慢更改數值時,可以照常設置數值。當我快速進行操作時,拇指滑塊卡在滑塊拇指的起始位置附近,從不設置該值。我不知道這是否重要,但肯定我必須寫下我在內容視圖控制器(內容視圖視圖)中註冊UIPanGestureRecognizer。當然,我正在添加結構圖。UITableView中的UISlider - 運動問題

enter image description here

+0

請問您能分享一下您嘗試過的代碼嗎? –

回答

0

我已經解決了它。這是UIPanGestureRecognizer的問題。代碼:

- (IBAction)panGesture:(UIPanGestureRecognizer *)recognizer { 
if ([recognizer.view isKindOfClass:[UISlider class]] || self.movieViewController) { 
    return; 
} 

if (recognizer.state == UIGestureRecognizerStateBegan) { 
    startLocation = [recognizer locationInView:self.view]; 

    if (startLocation.x < 25) { 
     [self.menuContainerViewController reloadData]; 
     [self hideBubble]; 
    } 
} 

if (isMenuShown) { 
    if (startLocation.x > self.view.frame.size.width - 25) { 
     CGPoint stopLocation = [recognizer locationInView:self.view]; 
     CGFloat distance = -self.view.frame.size.width + stopLocation.x; 
     [self movementAnimation:distance]; 
    } 
} 
else { 
    if (startLocation.x < 25) { 
     CGPoint stopLocation = [recognizer locationInView:self.view]; 
     CGFloat distance = -self.view.frame.size.width + stopLocation.x; 
     [self movementAnimation:distance]; 
    } 
} 

if (recognizer.state == UIGestureRecognizerStateEnded) { 
    CGRect frame = self.menuContainerViewController.view.frame; 

    if (frame.origin.x + frame.size.width > self.view.frame.size.width/2) { 
     [self slideInAnimation]; 
    } 
    else { 
     [self slideOutAnimation]; 
    } 
} 
} 

我加入到我的UIViewController:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { 
if ([touch.view isKindOfClass:[UISlider class]]) { 
    return NO; 
} 
return YES; 
} 

現在它像一個老闆!