当UIView可见时,如何获得通知?

编程入门 行业动态 更新时间:2024-10-12 01:27:43
本文介绍了当UIView可见时,如何获得通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有一种方法可以获得通知,回调或一些其他方法来调用一个方法,每当UIView变得可见的用户,即当UIScrollview是一些UIViews的超视图,并且这样的UIView的ViewController

Is there a way to get a notification, a callback or some other means to call a method whenever a UIView becomes visible for the user, i.e. when a UIScrollview is the superview of some UIViews, and the ViewController of such a UIView shall get notified when its view is now visible to the user?

我知道可能的,但不是那么优雅的解决方案,检查ScrollView滚动到哪个位置(通过UIScrollViewDelegate方法),并计算任何一个子视图是否可见... 但是我正在寻找一个更通用的方法来做这个。

I am aware of the possible, but not so elegant solution of checking to which position the ScrollView scrolled (via UIScrollViewDelegate-methods) and compute if either one of the subviews is visible... But I'm looking for a more universal way of doing this.

推荐答案

如果你的视图是展示行为,它应该在视图控制器中。在视图控制器上,每次视图出现时将调用viewDidAppear方法。

If your view is exhibiting behavior, it should be within a view controller. On a view controller, the viewDidAppear method will be called each time the view appears.

- (void)viewDidAppear:(BOOL)animated

更多推荐

当UIView可见时,如何获得通知?

本文发布于:2023-11-27 15:03:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638554.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何获得   通知   UIView

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!