UIView使用UITapGestures使用UIScrollView放大/缩小

时间:2014-01-02 09:26:14

标签: ios objective-c uiview uiscrollview uigesturerecognizer

我想放大/缩小我的UIView,但当我缩放视图时,我的自定义滚动视图不起作用意味着我无法滚动视图...

     self.scrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
self.scrollView.scrollEnabled = YES;
self.scrollView.minimumZoomScale=1.0;
self.scrollView.maximumZoomScale=2.0;
[self.scrollView setContentSize:CGSizeMake(self.view.frame.size.width*2, self.view.frame.size.height*2)];
self.scrollView.delegate=self;

[self.scrollView addSubview:self.view];

UITapGestureRecognizer *tripleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTripleTap:)];

[self.view addGestureRecognizer:tripleTap];

-(void)handleTripleTap:(UIGestureRecognizer *)g
{    
     if(self.scrollView.zoomScale > self.scrollView.minimumZoomScale)
    [self.scrollView setZoomScale:self.scrollView.minimumZoomScale animated:YES];
else
    [self.scrollView setZoomScale:self.scrollView.maximumZoomScale animated:YES];
}


- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return self.view;
}

请帮帮我...

...谢谢

0 个答案:

没有答案