简体   繁体   English

如何保持uiview的视野

[英]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.

相关问题 如何将UIView添加到CorePlot视图? - How to add UIView to the CorePlot view? UIView完成后如何保持键盘和关闭 - How to keep keyboard and dissmiss after finish with UIView 如何保持CAShapeLayer在其父UIView中? - How to keep CAShapeLayer to be inside its parent UIView? 使UIView用作表标题视图时保持其大小 - Making a UIView keep its size when used as a table header view iOs - 将uiview插入到代码中的另一个视图中,保持约束 - iOs - insert uiview into another view in code, keep constraints 如何检测UIView视图与另一个UIView的接近程度? - How do I detect how close UIView view is to the other UIView? 如果uiview包含子视图,如何在uiview中更改容器视图的位置 - How to change the position of a container view within an uiview if the uiview contains subviews 如何在Swift 4的视图控制器中的另一个uiview或图像上拖动多个uiview - How to drag multiple uiview on another uiview or image in a view controller in Swift 4 如何将UIView的一部分显示在UIView的视图层次结构的后面并朝前 - How to display part of a UIView at the back of a view hierarchy in a UIView towards the front 如何将情节提要UIView设置为视图的子类? - How to set storyboard UIView to subclass of view?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM