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

UIScrollView 中的固定/浮動視圖與 AutoLayout

Fixed / Float view in UIScrollView with AutoLayout(UIScrollView 中的固定/浮動視圖與 AutoLayout)
本文介紹了UIScrollView 中的固定/浮動視圖與 AutoLayout的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

在 此技術說明中,Apple 聲明您可以通過向 UISCrollView 的超級視圖添加約束來固定/浮動 UIScrollView 的子視圖.我試過了,但我做錯了,我不知道是什么問題.

In this technical Note Apple states that you can make a subview of UIScrollView fixed / floating by adding constraints to UISCrollView's superview. I tried that but I'm doing something wrong and I can't figure out whats the problem.

請注意,您可以通過在視圖和滾動視圖的子樹之外的視圖(例如滾動視圖的超級視圖)之間創建約束,使滾動視圖的子視圖看起來浮動(不滾動)在其他滾動內容之上.

Note that you can make a subview of the scroll view appear to float (not scroll) over the other scrolling content by creating constraints between the view and a view outside the scroll view’s subtree, such as the scroll view’s superview.

這就是我所做的.我已經設置了 UIScrollView 并嘗試將固定視圖添加到滾動視圖的頂部,如下所示:

That's what I did. I have a UIScrollView already set up and try to add the fixed view to the top of the scrollview like the following:

_testOverlay = [[UIView alloc] init];
_testOverlay.backgroundColor = [UIColor blueColor];
_testOverlay.translatesAutoresizingMaskIntoConstraints = NO;
[self.scrollView addSubview:_testOverlay];

[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[_testOverlay]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_testOverlay)]];
[self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:|[_testOverlay(64)]-(>=0)-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(_testOverlay)]];

但是,這不起作用,添加的視圖將與滾動視圖一起移動并且不會浮動".有什么想法嗎?

However, this does not work, the added view will move along with the scrollview and does not 'float'. Any ideas whats wrong here?

推薦答案

在視圖和滾動視圖子樹之外的視圖之間,例如滾動視圖的超級視圖.

這部分很關鍵.self.scrollView_testOverlay 的超級視圖.因此,在 @"|[_testOverlay]|" 中,豎線引用 self.scrollView.你必須用 _testOverlay 和(我想)self.view 之間的約束替換這個約束.我不確定視覺格式語言是否可行,但您當然可以使用 constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant 來實現.它會是這樣的(我不會發布整個代碼,因為它很長):

This part is critical. self.scrollView is a superview of _testOverlay. So, in @"|[_testOverlay]|" vertical bars reference self.scrollView. You have to replace this constraint with the constraint between _testOverlay and (I suppose) self.view. I'm not sure if it's possible with the visual format language, but you certainly can do it with constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant. It would go like this (I won't post the whole code, because it's looong):

[self.view addConstraint:[NSLayoutConstraint
                          constraintWithItem:self.view
                          attribute:NSLayoutAttributeLeft
                          relatedBy:NSLayoutRelationEqual
                          toItem:_testOverlay
                          attribute:NSLayoutAttributeLeft
                          multiplier:1.0
                          constant:0]];

這篇關于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精品国产综合久久久久久蜜臀 | 在线免费观看黄a | 亚洲日日夜夜 | 99精品国产一区二区青青牛奶 | 欧美日韩亚洲视频 | 91污在线 | 亚洲精品自拍视频 | 黄色免费在线观看 | zzzwww在线看片免费 | 精品久久久久国产 | 亚洲精品一区二区三区蜜桃久 | 中文字幕日韩专区 | 欧洲精品码一区二区三区免费看 | 91在线网站 | 日韩最新网址 | 日韩中文字幕 | 天堂中文资源在线 | 精品美女视频在免费观看 | 精品国产aⅴ | 在线免费看毛片 | 欧美日本在线观看 | 久久在线视频 | 成人av一区二区三区 | 一区二区精品在线 | 夜夜操天天艹 | 99色在线视频| 国产一区久久 | 久久99精品久久 | 日韩精品视频一区二区三区 | 99免费精品 | 午夜久久久久久久久久一区二区 | 超碰在线影院 | 嫩草视频在线免费观看 | 久久久成人精品 | 欧美一级免费看 | 国产精品一区二区在线 | www日本高清视频 | 精品一区二区三区在线视频 | 亚洲精品一区二区 |