如何确定视图是否已第一次加载? [英] How can I determine if a view has been loaded for the first time?

查看:116
本文介绍了如何确定视图是否已第一次加载?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检测第一次显示我的视图。之后,我不会忘记它。在哪里可以设置一个BOOL来做这个?

I want to detect the very first time my view is displayed. After that, I wan't to forget about it. Where can I set a BOOL to do this?

推荐答案

跟踪每次viewDidLoad已被调用,并且第一次将视图上的标签设置为1.然后您可以在其他位置测试标签值。

Just off the top of my head you could set a static var which keeps track of every time "viewDidLoad" has been called, and the first time it is set the tag on the view to 1. Then you ca test the tag value elsewhere.

这篇关于如何确定视图是否已第一次加载?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆