나는 내부에 HTML이있는 scrollview 및 uiwebview가있는보기를 가지고 있습니다. 스크롤 뷰를 천천히 자동으로 아래쪽으로 스크롤하려고 할 때, 터치 할 때 일시 중지 한 다음 현재 위치에서 애니메이션을 다시 시작하려고합니다.UIScrollView 애니메이션 있음 제스처 터치에서 일시 중지 및 다시 시작
지금 당장은 html 표시, scrollview 스크롤 및 스크롤을 멈추는 터치가 있지만 터치 한 후 일정 시간이 지나면 현재 위치에서 다시 스크롤 애니메이션을 시작할 수 없습니다. .
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *myHTML = @"<html><body><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1><h1>Hello, world!</h1></body></html>";
[self.webView loadHTMLString:myHTML baseURL:nil];
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(userDidTapWebView)];
[self.webView addGestureRecognizer:recognizer];
recognizer.delegate = self;
[recognizer release];
//Start the scrolling
[self startAnimation];
}
#pragma mark - Gesture Delegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldReceiveTouch:(UITouch *)touch {
//Stop the scrollview from scrolling when the screen is touched
[self.scrollView.layer removeAllAnimations];
return YES;
}
#pragma mark - Animate Methods
-(void)startAnimation{
[UIScrollView beginAnimations:@"scrollAnimation" context:nil];
[UIScrollView setAnimationDuration:8.0f];
[self.scrollView setContentOffset:CGPointMake(0 , 100)];
[UIScrollView commitAnimations];
}
-(void)dealloc{
[super dealloc];
[self.webView release];
[self.scrollView release];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
코드를 구현했는데 대리자 메서드가 아직 선택되지 않았습니다. – user1079052
위임 방법은 무엇입니까? –