问题描述
我不明白为什么滚动视图不起作用,因为我遵循了教程中的建议.
i don't understand why the scrollview isn't working, because i followed advices from tutorials.
我创建了包含 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;
}
角落落的光