久久久久久久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 可縮放?)
主站蜘蛛池模板: 日日夜夜天天久久 | 91 久久| 日韩在线视频观看 | 午夜影院黄 | 色婷婷综合在线观看 | 日韩av电影院 | 久久久久国产一级毛片高清网站 | 亚洲国产成人在线观看 | 99pao成人国产永久免费视频 | 久久久久高清 | 国产成人精品一区二 | 国产精品久久久久久高潮 | 中文字幕亚洲精品 | 国产精品99久久久久久宅男 | 色免费视频 | 99在线国产 | 国产免费一区二区三区网站免费 | 91亚洲精品国偷拍自产在线观看 | 久草视频网站 | 亚洲精品一区二区在线观看 | 亚洲国产看片 | 久久久久免费精品国产 | 最新国产精品精品视频 | 一区二区三区免费 | 国产精品国产精品国产专区不片 | 午夜精品久久久久久久久久久久久 | 欧美成视频 | 久久久亚洲一区 | 午夜久久av | 久久久久99 | 日韩精品久久久久 | 日本中出视频 | 国产一级大片 | 国产成人免费 | 精品国产乱码久久久久久老虎 | 亚洲国产成人精 | 亚洲激情网站 | 欧美成人影院在线 | 国产精品无码久久久久 | 国产精品美女在线观看 | 国产精品视频网 |