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

方向更改時的 UIScrollview 內容大小

UIScrollview content size when orientation changes(方向更改時的 UIScrollview 內容大小)
本文介紹了方向更改時的 UIScrollview 內容大小的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我有一個帶有分頁的滾動視圖.在 viewDidLoad 我檢查當前方向是否為橫向,然后我將其 contentsize 的高度設置為 440

I have a scrollview with pagination. In viewDidLoad i check if the current orientation is landscape then i set its contentsize's height 440

 if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])) 
    {
        [scroll      setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages,340)];


    }
    else if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation]))

    {
        [scroll setFrame:CGRectMake(0,0,480,480)];
        [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 440)];


    }

一切正常滾動視圖滾動流暢,沒有對角滾動.

everything works fine scrollview scrolls smoothy and there is no diagonal scrolling.

但是當方向改變時,

我必須再次設置滾動視圖的框架和內容大小,我將其設置如下

i have to set scrollview's frame and contentsize again and i am setting it as follow

-(void)orientationChanged:(id)object
{
if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
{
    self.scroll.frame = [[UIScreen mainScreen]bounds];

    [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 340)];
}


else
{
 self.scroll.frame = CGRectMake(0,0,480,480);
        [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 600)];
}


}

我不明白為什么我必須在橫向模式下將內容大小的高度設置為 600,這還不夠.它又增加了一個問題,即滾動視圖開始對角滾動,這是我不想要的,因為它看起來很奇怪.誰能幫助我了解我在哪里以及缺少什么?

i cant understand why i have to set content size's height upto 600 in landscape mode, and that too isnt enough. and it adds one more problem that scrollview starts scrolling diagonally which i dont want as it looks so weird. Can anyone help me understanding where and what i am missing?

我已將滾動視圖的自動調整大小掩碼設置為

i have set scrollview's autoresizing mask as

[scroll setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleHeight];

但改變它沒有幫助.

推薦答案

這是您的代碼中的問題.為什么要這樣設置幀大小?你只有 320px width 的屏幕尺寸.而當它變為landscape時,高度將只有320px.但是您將滾動 height 設置為 480px 并且它 走出屏幕 并且 開始對角滾動.

Here it is a problem in your code. Why you are setting the frame size like this?? You have only the screen size of 320px width. And when it changes to landscape, height will be only 320px. But you are setting the scroll height as 480px and it goes out of the screen and start to scroll diagonally.

self.scroll.frame = CGRectMake(0,0,480,480);

不是那個幀大小,而是像這樣改變

Instead of that frame size, change like this

self.scroll.frame = CGRectMake(0,0,480,320);

您需要設置內容大小,具體取決于您在任一方向的滾動視圖中擁有的內容.

And you need to set the content size depend on the content you are having inside the scroll view in either orientation.

這篇關于方向更改時的 UIScrollview 內容大小的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 可縮放?)
主站蜘蛛池模板: 亚洲日本中文字幕在线 | 国产成人一区二区三区电影 | 亚洲精品在线观看视频 | 久久久久久国产精品 | 久草中文在线 | 韩国主播午夜大尺度福利 | 成人一级黄色毛片 | 天天操夜夜操免费视频 | 免费午夜视频在线观看 | 精品在线一区 | 国产精品免费视频一区 | 亚洲高清免费视频 | 欧美在线精品一区 | 久久综合一区二区 | 欧美二区在线 | 天天看天天操 | 国产一区二区 | 亚洲v日韩v综合v精品v | 国产精品视频网站 | 亚洲精品福利在线 | 日韩在线国产 | 玖玖视频 | 五月天天丁香婷婷在线中 | 先锋资源亚洲 | 欧美日韩a | xxx.在线观看 | 综合一区二区三区 | 国产99久久精品一区二区永久免费 | 99视频网 | 亚洲协和影视 | 国产成人99av超碰超爽 | 亚洲二区在线 | 91在线区| 999视频 | 美女天天操 | 国产日韩欧美激情 | 男人av网 | 欧美精品一区二区三区在线播放 | 久久久久一区 | 国产成人在线观看免费 | 性高湖久久久久久久久3小时 |