[英]how to keep uiview in view
i have a view that is required to be stayed on the view when the user scroll up or down in a scrollview. 我有一个视图,当用户在scrollview中向上或向下滚动时,该视图必须保留在该视图上。
i managed to let it stay on top of the view but how can i allow it to stay at the bottom of the view when i scroll down ? 我设法让它停留在视图顶部,但是当我向下滚动时如何允许它停留在视图底部? EDIT: attached picture to explain better. 编辑:附上图片以更好地说明。
the view will alway be visible on the view. 该视图将始终在视图上可见。
-(void) scrollViewDidScroll:(UIScrollView *)scrollView
{
NSLog (@"Content Offset: %f", self.playlistTableview.contentOffset.y);
if (self.playlistTableview.contentOffset.y > playerPosition) // will keep the view at the top
{
CGRect newFrame = self.playerView.frame;
newFrame.origin.x = 0;
newFrame.origin.y = +self.playlistTableview.contentOffset.y;
[self.playerView setFrame: newFrame];
}
}
you can see how the NZD have a top overlay that stops 您可以看到NZD的顶部叠加层如何停止
Try to add your ScrollView and Always Stay view in a container view. 尝试在容器视图中添加ScrollView和Always Stay视图。 So it will not scroll when you do scroll the scroll view. 因此,当您滚动滚动视图时,它将不会滚动。 and anytime you can change your always stay view to different frame to top or bottom as u needed 而且您随时可以根据需要将始终停留视图更改为顶部或底部的不同框架
UIView--->
1st subview--->UIScrollView
2nd subview--->Don't ScrollMeView/Always Stay view
I think you have added your view in contain of UIScrollView. 我认为您已经在包含UIScrollView的视图中添加了视图。
I mean, main container for your view is UIScrollview, so it'll work as subview of UIScrollview and will follow scrollview properties. 我的意思是,视图的主要容器是UIScrollview,因此它将用作UIScrollview的子视图,并将遵循scrollview属性。 Can you please try to add your view on main view. 能否请您尝试在主视图上添加视图。
[self.view addSubView:yourViewObj];
If that comes behind the scrollView, then please try with 如果在滚动视图后面,请尝试
[self.view bringSubviewToFront:yourViewObj];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.