久久久久久久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

有什么想法嗎?

推薦答案

那是因為你的滾動視圖邊界的大小大于你的內(nèi)容大小.內(nèi)容大小需要是圖像視圖的實際大小,可見大小由框架/邊界設置.我猜你想在 {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模板網(wǎng)!

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

相關文檔推薦

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(以編程方式創(chuàng)建部分屏幕 UIPageViewController)
how to make an ImageView zoomable with or without ScrollView.?(如何使用或不使用 ScrollView 使 ImageView 可縮放?)
UIImageView zoom and pinch in UIScrollView(UIImageView 在 UIScrollView 中縮放和捏合)
主站蜘蛛池模板: 国产传媒毛片精品视频第一次 | 秋霞影院一区二区 | 91www在线观看 | 久久久蜜桃 | 亚洲 欧美 日韩在线 | 亭亭五月激情 | 91在线网站 | 一区二区三区四区在线视频 | 国产一级免费视频 | 日本在线观看视频 | 久草视频观看 | 久久精品aaa | 久久九七 | 日韩免费看片 | 第一区在线观看免费国语入口 | 国产精品国产a级 | 每日更新av | 亚洲国产激情 | 91国内外精品自在线播放 | 成人小视频在线免费观看 | 中文在线一区二区 | 一区二区三区在线免费观看 | 国产精品视频播放 | 亚洲国产一区二区在线 | 久久精品亚洲一区二区三区浴池 | 欧美伊人久久久久久久久影院 | 一区二区三区电影在线观看 | 日韩欧美在线视频一区 | 91国内精品久久 | 欧美白人做受xxxx视频 | 精品一区二区三区在线观看国产 | 福利视频网址 | 夜夜爽99久久国产综合精品女不卡 | 亚洲视频中文字幕 | 亚洲日韩欧美一区二区在线 | 欧美极品一区二区 | 久久久无码精品亚洲日韩按摩 | 操操日 | 午夜激情在线 | 91av在线不卡| 一级欧美|