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

UIScrollView AutoLayout 僅垂直

UIScrollView AutoLayout Vertical Only(UIScrollView AutoLayout 僅垂直)
本文介紹了UIScrollView AutoLayout 僅垂直的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我想讓 AutoLayout 與 UIScrollView 一起工作,但遇到了一些麻煩.這是我所做的:

  1. 在主視圖中添加一個 UIScrollView 框架:[top: 0, left: 0, width: 320, height: 568]

  2. UIScrollView 中添加 UIView "ContentView",帶有框架和 bgcolor black: [top: 0, left: 0, width: 320, height: 568]

  3. 設置UIScrollView約束:[top: 0, bottom: 0, left: 0, right: 0]

  4. 設置ContentView"約束:[top: 0, bottom: 0, left: 0, right: 0]

  5. 對齊ContentView"內的項目

  6. 將主視圖的 bgcolor 設置為灰色(以查看發生了什么)

這是問題的截圖:

self.scrollView.directionalLockEnabled = YES;

I want to get the AutoLayout working with the UIScrollView and am having a little trouble with it. Here is what I did:

  1. Add a UIScrollView inside the Main View with frame: [top: 0, left: 0, width: 320, height: 568]

  2. Add UIView "ContentView" inside the UIScrollView with frame and bgcolor black: [top: 0, left: 0, width: 320, height: 568]

  3. Setup UIScrollView constraints: [top: 0, bottom: 0, left: 0, right: 0]

  4. Setup "ContentView" constraints: [top: 0, bottom: 0, left: 0, right: 0]

  5. Align the items inside the "ContentView"

  6. Set Main View bgcolor to gray (to see what's going on)

Here is a screenshot of the problem:

1

For some reason, the constraints make the content view be in the middle of the screen. Also, it scrolls in every direction. I want the content to be scrollable only in vertical direction like in UITableView. so that I can't move it like below:

What am I doing wrong? I have checked all the tutorials and answers I can find in StackOverflow and Google, and no one actually has just a bizarre problem, so I am asking for help.

EDIT: I also added ContentView's width and height as constraints and that didn't help either.

解決方案

For disabling the horizontal scroll, you can set the content size in the (void)scrollViewDidScroll method.

[self.scrollView setContentOffset: CGPointMake(0, self.scrollView.contentOffset.y)];

You'll also want to set the directional lock so only 1 scroll direction is used at a time. https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIScrollView_Class/index.html#//apple_ref/occ/instp/UIScrollView/directionalLockEnabled

self.scrollView.directionalLockEnabled = YES;

這篇關于UIScrollView AutoLayout 僅垂直的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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国产精品 | 久久久久香蕉视频 | 极品销魂美女一区二区 | 麻豆91av | 久久九九99 | 久久久国产视频 | 国产精品网址 | 天堂中文字幕av | 99精品视频免费在线观看 | 操视频网站| 精品免费在线 | 黄免费在线 | 国产视频精品在线观看 | 亚洲国产一区二区三区四区 | 91国产视频在线 | 精品美女视频在线观看免费软件 | 91精品久久久 | 欧美精品第一页 | 成人免费淫片aa视频免费 | 亚洲 自拍 另类 欧美 丝袜 | 国内精品久久久久久 | 日韩欧美一区二区三区免费观看 | 国产大片一区 | 日本视频一区二区三区 | 欧美综合久久久 | 欧美日韩国产中文 | 国产日产精品一区二区三区四区 | 成人在线免费观看视频 | 成人午夜免费在线视频 | www.亚洲一区 | 亚洲国产精品久久久久秋霞不卡 | 久久精品国产亚洲一区二区 | 一区二区在线视频 | 岛国在线免费观看 | 嫩草视频入口 | 成人精品一区二区三区 | 国产丝袜一区二区三区免费视频 | 国产精品国产三级国产aⅴ原创 | 精品视频一区二区三区在线观看 | 黄色片在线 | 夜夜撸av|