久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

盡管 contentSize 小于 UIImageView,但 UIScrollView 不滾

UIScrollView not scrolling although contentSize is smaller than UIImageView(盡管 contentSize 小于 UIImageView,但 UIScrollView 不滾動)
本文介紹了盡管 contentSize 小于 UIImageView,但 UIScrollView 不滾動的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

所以我有一個 UIImageView 作為 UIScrollView 的子視圖,我將 contentSize 設置為小于 UIImageView 寬度和高度,但是它不允許我滾動.. 這是為什么?這是一些代碼:

So I have a UIImageView as a subview of UIScrollView, I've set the contentSize to be smaller than the UIImageView width and height, however it doesn't allow me to scroll.. why is this? Here's some code:

UIImage * image = [UIImage imageWithData:data];
                UIImageView * imgView = [[UIImageView alloc] initWithImage:image];
                [imgView setUserInteractionEnabled:YES];
                //[imgView setContentMode:UIViewContentModeScaleAspectFill];
                [imgView setBackgroundColor:[UIColor clearColor]];
                [imgView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
                [imgView setFrame:CGRectMake(0, 0, imgView.frame.size.width, imgView.frame.size.height)];

                CGRect imgFrame;
                imgFrame.size.width = originalImageSize.width;
                imgFrame.size.height = originalImageSize.height;
                imgFrame.origin.x = imageOriginPoint.x;
                imgFrame.origin.y = imageOriginPoint.y;

                UIScrollView * imgScrollView = [[UIScrollView alloc] initWithFrame:imgFrame];
                [imgScrollView setScrollEnabled:YES];
                [imgScrollView setClipsToBounds:YES];
                [imgScrollView addSubview:imgView];
                [imgScrollView setBackgroundColor:[UIColor clearColor]];


  [imgScrollView setFrame:imgFrame];
                [imgScrollView setContentSize:CGSizeMake(200, 200)];

SCROLL VIEW CONTENT SIZE WIDTH IS 200.000000 AND HEIGHT CONTENT SIZE IS 200.000000
UIIMAGE VIEW WIDTH IS 2240.225830 AND HEIGHT IS 2240.225830
SCROLL VIEW FRAME WIDTH IS 768.000000 AND SCROLL VIEW FRAME HEIGHT IS 768.000061

有什么想法嗎?

推薦答案

那是因為你的滾動視圖邊界的大小大于你的內容大小.內容大小需要是圖像視圖的實際大小,可見大小由框架/邊界設置.我猜你想在 {200, 200} 大小的矩形中滾動圖像?試試這個:

That's because that your size of bounds of scroll view is larger than your content size. The content size need to be the actual size of image view, and the visible size is set by frame / bounds. I guess you want to scroll a image in a {200, 200} sized rect? Try this:

        UIScrollView * imgScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)]; // this is your visible rect
        [imgScrollView setScrollEnabled:YES];
        [imgScrollView setClipsToBounds:YES];
        [imgScrollView addSubview:imgView];
        [imgScrollView setBackgroundColor:[UIColor yellowColor]];

        [imgScrollView setContentSize:imgFrame.size]; // this is your image view size

這篇關于盡管 contentSize 小于 UIImageView,但 UIScrollView 不滾動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Stop a UITableView from automatically scrolling(阻止 UITableView 自動滾動)
iOS UIScrollView Lazy Loading(iOS UIScrollView 延遲加載)
using iOS 6.0 SDK and building for iOS 5 Target causes UIScrollView setMinimumZoomScale to fail when running on iOS 5 simulator(在 iOS 5 模擬器上運行時,使用 iOS 6.0 SDK 并為 iOS 5 Target 構建會導致 UIScrollView setMinimumZ
Create partial-screen UIPageViewController programmatically(以編程方式創建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
UIImageView zoom and pinch in UIScrollView(UIImageView 在 UIScrollView 中縮放和捏合)
主站蜘蛛池模板: 91在线精品视频 | 欧美精品一区二区在线观看 | 伊人久久综合 | 日韩精品视频中文字幕 | 午夜影院在线观看免费 | 久久久久久久久久久久亚洲 | 91精品一区 | 久久久久亚洲精品中文字幕 | 日韩精品一区二区三区在线播放 | 色久伊人 | 久久久久国产精品 | 国产三级精品三级在线观看四季网 | 男女网站免费 | av在线免费观看网站 | 久久亚洲综合 | 九九色综合 | 视频在线h | 亚洲国产成人精品久久久国产成人一区 | 精品国产乱码久久久久久丨区2区 | 精品96久久久久久中文字幕无 | 国产精品中文 | 亚洲欧洲成人av每日更新 | 久久小视频 | 午夜精品久久久久久久久久久久 | 亚洲综合色视频在线观看 | 日本精品999 | 国产在线看片 | 亚洲欧美一区二区三区视频 | 日韩成人高清 | 日韩视频在线免费观看 | 在线观看h视频 | 天天搞天天操 | 午夜影院中文字幕 | 日本三级在线 | 日韩亚洲视频 | 男女下面一进一出网站 | 欧美日韩一区精品 | 91精品国产乱码久久蜜臀 | 久久精品国产一区 | 啪啪精品 | 欧美一级二级在线观看 |