久久久久久久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 中縮放和捏合)
主站蜘蛛池模板: 亚洲精选久久 | 亚洲毛片在线 | 国产成人免费 | 精品一区二区三区在线视频 | 久久久精品一区 | 国产精品精品久久久 | 色偷偷噜噜噜亚洲男人 | 午夜国产羞羞视频免费网站 | 91精品国产综合久久婷婷香蕉 | 欧美一级黄色片在线观看 | 成人亚洲视频 | 国产精品激情 | 久久久久久女 | 国产欧美精品一区二区色综合 | 日韩欧美一级片 | 日韩三级免费观看 | 99精品一区二区三区 | 一区二区中文字幕 | 偷拍自拍第一页 | 日韩欧美一区二区三区四区 | 欧美在线观看一区 | 久草免费在线视频 | 男女羞羞视频免费 | 午夜午夜精品一区二区三区文 | 一区二区三区国产好的精 | 午夜精品一区二区三区在线观看 | 午夜视频一区二区三区 | 亚洲国产精品一区二区三区 | 午夜精品久久久久久久99黑人 | 一区二区三区亚洲 | 特级特黄特色的免费大片 | 视频一区中文字幕 | 亚洲视频在线一区 | 亚洲品质自拍视频 | h片在线播放 | 欧美aⅴ片 | 国产一区免费 | 欧美性a视频| 日韩午夜精品 | 欧美在线 | 伊人二区 |