久久久久久久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 可縮放?)
主站蜘蛛池模板: 国产精品不卡一区 | 国产午夜亚洲精品不卡 | 美女中文字幕视频 | 国产一区久久久 | 第四色影音先锋 | 成年无码av片在线 | 国产视频一区二区 | 国产精品一区二区av | 欧美一级免费 | 91九色porny首页最多播放 | 99热这里 | 久久中文字幕一区 | 久久久高清 | 久久精品亚洲一区二区三区浴池 | 午夜免费电影 | 2018中文字幕第一页 | 羞羞视频一区二区 | 国产精品地址 | 日韩中文在线观看 | 久久久久久久久国产成人免费 | 可以看黄的视频 | 天天拍天天插 | 亚洲精品久久区二区三区蜜桃臀 | 国产一区二区在线免费 | 国产黄色大片 | 国产日韩欧美在线一区 | 日韩在线不卡视频 | 国产综合久久 | 国产精品成人一区二区三区 | 国产成人短视频在线观看 | 九九综合| 黄色免费网站在线看 | 精品国产一级 | 日韩在线视频一区 | 性网站免费| 国产精品婷婷 | 99视频免费在线 | 在线视频h | 国产在线一 | 欧洲一级毛片 | 在线播放中文字幕 |