久久久久久久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 可縮放?)
主站蜘蛛池模板: 蜜桃臀av一区二区三区 | 亚洲精品免费观看 | 精品欧美乱码久久久久久1区2区 | 熟女毛片| 一区二区视频在线观看 | 欧美精品一区在线发布 | 男人av的天堂 | 国产福利资源 | 免费国产视频在线观看 | 国产精品久久久久久亚洲调教 | 国产一区在线看 | 精品久久一区 | 亚洲国产成人精品女人久久久 | 国产成人综合一区二区三区 | 国产精品1区2区 | 成人午夜免费网站 | a黄视频| 午夜ww| а_天堂中文最新版地址 | 日本久久精 | 国产女人精品视频 | 中文精品视频 | 97av在线 | 性色在线 | 国产精品日韩一区二区 | www亚洲精品 | 国产不卡在线观看 | 日韩欧美视频免费在线观看 | 亚洲精品一区二区在线观看 | 欧洲色| 国产日韩精品一区 | 欧美乱大交xxxxx另类电影 | 国产视频一区二区 | 91久久夜色 | 亚洲一区在线播放 | 亚洲免费视频播放 | 91精品在线播放 | 成人网av | 免费看淫片 | 亚洲一级在线 | 国产欧美一区二区三区在线看蜜臀 |