本文介紹了uiscrollview 的縮放不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我不明白為什么滾動視圖不起作用,因為我遵循了教程中的建議.
I don't understand why the scrollview isn't working, because I followed advices from tutorials.
我創(chuàng)建了包含 UIImageView
的 UIScrollView
并且還添加了方法
I created the UIScrollView
that contains an UIImageView
and I also added the method
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
return imgv;
}
和界面中的UIScrollViewDelegate
,但它不起作用.
and the UIScrollViewDelegate
in the interface, but it isn't working.
這是 UIScrollView
的代碼:
imgv = [[UIImageView alloc]
initWithFrame:CGRectMake(0, 0, 1000, 500)];
imgv.image = [UIImage imageWithData:retrievedData];
scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 800, 800)];
scrollView setContentSize:CGSizeMake(imgv.image.size.width, imgv.image.size.height)];
scrollView.maximumZoomScale = 4;
scrollView.minimumZoomScale = 1;
[scrollView setScrollEnabled:YES];
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(hideImageView)];
[scrollView addSubview:imgv];
[view addSubview:scrollView];
如果有人能找出問題所在,我將不勝感激.
I would be thankful, if someone could figure out what the problem could be.
推薦答案
你需要在你的委托方法中返回 imgv
viewForZoomingInScrollView::
You need to return imgv
in your delegate method viewForZoomingInScrollView::
- (UIView *) viewForZoomingInScrollView:(UIScrollView *) view {
return imgv;
}
這篇關(guān)于uiscrollview 的縮放不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!