Tuesday, June 4, 2013

UIScrollView canCancelContentTouches example in Objective C (iOS).


UIScrollView canCancelContentTouches

A Boolean value that controls whether touches in the content view always lead to tracking.

@property(nonatomic) BOOL canCancelContentTouches

Discussion of [UIScrollView canCancelContentTouches]
If the value of this property is YES and a view in the content has begun tracking a finger touching it, and if the user drags the finger enough to initiate a scroll, the view receives a touchesCancelled:withEvent: message and the scroll view handles the touch as a scroll. If the value of this property is NO, the scroll view does not scroll regardless of finger movement once the content view starts tracking.

UIScrollView canCancelContentTouches example.
THe UIScrollView might be catching all the touch events.

Maybe try a combination of the following:

_scrollView.delaysContentTouches = NO;
_scrollView.canCancelContentTouches = NO;
and

bookView.userInteractionEnabled = YES;

Example of [UIScrollView canCancelContentTouches].
@implementation ScrollViewWithPickers

- (UIView *) hitTest : (CGPoint)point withEvent : (UIEvent *)event

   UIView * v = [super hitTest : point withEvent : event];
  
   if ([@"UIPickerTable" isEqualToString:[[v class] description]]) {
      self.canCancelContentTouches = NO;
      self.delaysContentTouches = NO;
   } else {
      self.canCancelContentTouches = YES;
      self.delaysContentTouches = YES;
   }
  
   return v;
}

UIScrollView canCancelContentTouches example.
-(IBAction)loadNext:(id)sender{
start+=IMAGE_PAGING_COUNT;
[moreButton removeFromSuperview];

//サムネイルの高さを+する
thumnailHeight+=imageListHeight;
NSLog(@"height:%d",thumnailHeight);
thumbnailView.frame = CGRectMake(0, 0, self.view.frame.size.width,
thumnailHeight);
thumbnailView.indicatorStyle = UIScrollViewIndicatorStyleBlack;
thumbnailView.clipsToBounds = YES;
thumbnailView.scrollEnabled = YES;
thumbnailView.canCancelContentTouches = NO;
[self feedHistoryImage];
}

End of UIScrollView canCancelContentTouches example article.