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

UIScrollView setZoomScale:animated messes scrollView 縱橫比

UIScrollView setZoomScale:animated messes scrollView aspect ratio(UIScrollView setZoomScale:animated messes scrollView 縱橫比)
本文介紹了UIScrollView setZoomScale:animated messes scrollView 縱橫比的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在開發一個應用程序,其視圖包含一個 UISCrollView,內部是一個 UIImageView.

I am developing an app with a view that holds a UISCrollView, inside which is a UIImageView.

當視圖即將出現時,我執行了 setZoomScale 操作:

When the view is about to appear, I perform a setZoomScale operation:

-(void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    NSLog(@"bounds of current view");
    NSLog(@"widht: %f, height: %f", self.view.bounds.size.width,self.view.bounds.size.height);
    NSLog(@"size of the image");
    NSLog(@"widht: %f, height: %f", self.imageView.image.size.width,self.imageView.image.size.height);
    NSLog(@"size of the scrollView BEFORE resizing");
    NSLog(@"widht: %f, height: %f", self.scrollView.contentSize.width,self.scrollView.contentSize.height);
    [self.scrollView setZoomScale:0.5 animated:NO];
    NSLog(@"size of the scrollView AFTER resizing");
    NSLog(@"widht: %f, height: %f", self.scrollView.contentSize.width,self.scrollView.contentSize.height);
}

問題是如果圖像是正方形的,在應用 setZoomScale 之后,scrollView 就不再是正方形了.這是運行上述代碼的輸出:

The problem is that if the image is a square one, after applying setZoomScale the scrollView is not square anymore. Here is the output of running the above code:

2012-01-16 21:41:01.678 WorldTour[22781:f803] bounds of current view
2012-01-16 21:41:01.680 WorldTour[22781:f803] widht: 320.000000, height: 367.000000
2012-01-16 21:41:01.681 WorldTour[22781:f803] size of the image
2012-01-16 21:41:01.682 WorldTour[22781:f803] widht: 612.000000, height: 612.000000
2012-01-16 21:41:01.683 WorldTour[22781:f803] size of the scrollView BEFORE resizing
2012-01-16 21:41:01.683 WorldTour[22781:f803] widht: 612.000000, height: 612.000000
2012-01-16 21:41:01.684 WorldTour[22781:f803] size of the scrollView AFTER resizing
2012-01-16 21:41:01.685 WorldTour[22781:f803] widht: 306.000000, height: 259.500000

因此,運行代碼后,612x612 的方形滾動視圖變成了 306x259.5.我錯過了什么?出了什么問題?

So, after running the code, a square scrollView of 612x612 turns out to be 306x259.5. What am I missing? What is going wrong?

不應該 [self.scrollView setZoomScale:0.5 animated:NO];用同樣的方式變換高度和寬度?

Shouldn't [self.scrollView setZoomScale:0.5 animated:NO]; transform height and width the same way?

推薦答案

好的,經過多次嘗試,我終于成功了!我不知道到底是什么導致了這個問題,但是在故事板中選擇了滾動視圖,我選擇了 XCode 中的屬性檢查器,然后取消選中自動調整子視圖".取消選中后,一切正常.scrollView 已正確調整大小.

Ok, after a lot of tries I finally got it working! I don't know exactly what was causing the problem, but with the scrollView selected in the storyboard I selected the Attributes Inspector inside XCode, and then unchecked "Autoresize Subviews". After unchecking it, it all works ok. The scrollView is correctly resized.

我解決了這個問題,但不明白是什么導致了問題,所以如果你知道為什么會發生這種情況,請隨時發表評論!

I solved this but don't understand what's causing the problem, so if you know why this happens feel free to comment!

這篇關于UIScrollView setZoomScale:animated messes scrollView 縱橫比的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

相關文檔推薦

how to set scrollview content size in swift 3.0(如何在 swift 3.0 中設置滾動視圖內容大小)
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 可縮放?)
主站蜘蛛池模板: www久久国产 | 永久www成人看片 | 天天操 天天操 | 中文字幕综合 | 日本在线观看视频 | 国内91在线 | 2021狠狠天天天 | 97在线播放 | 国产精品小视频在线观看 | 国产精品一区二区久久精品爱微奶 | 欧美日韩一区精品 | 亚洲毛片在线观看 | 天天躁日日躁狠狠很躁 | 欧美一区不卡 | 欧美aaaaaaaaaa| 欧美在线一区二区三区 | 国产成人免费在线 | 国产激情91久久精品导航 | 精品影院 | 日韩精品视频在线观看一区二区三区 | 欧美亚洲综合久久 | 日韩久草 | 亚洲一区二区在线 | 婷婷国产一区 | 天天久久 | 精品国产乱码久久久久久图片 | 日韩欧美一二三区 | 在线国产视频 | 国产精品久久久久久久久久久久午夜片 | gogo肉体亚洲高清在线视 | 国产精品久久久久久久久久久久久 | 久热国产精品视频 | 在线日韩欧美 | 欧美激情精品久久久久久 | 中文字幕在线一区二区三区 | 日韩欧美精品 | 亚洲色在线视频 | 大象一区 | 欧美激情在线播放 | 亚洲欧美视频一区 | 超碰成人免费 |