开发者

Is there a way to literally pause the view?

开发者 https://www.devze.com 2023-03-24 02:08 出处:网络
Can I pause a view for a certain amount of time? Basically, while an action is occurring, my view becomes messed up and I cannot figure out why. Everything gets shifted, and I\'ve been looking through

Can I pause a view for a certain amount of time? Basically, while an action is occurring, my view becomes messed up and I cannot figure out why. Everything gets shifted, and I've been looking through the code line by line for hours. So can I prevent the view from changing itself and then somehow resume it after the action is over? I really don't know开发者_高级运维 if this is a stupid question, but thanks for your help!


The action is sending something to a server, for whatever reason the entire view is shifted. After the view is shifted, I have the coordinates outputted to the log, and it thinks the view is at 0,0, even though it's not.

I think you might be getting mixed up in the distinction between frames & bounds?

From this link

The frame of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within.

The bounds of an UIView is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).

Essentially, if you're looking at the origin coordinates of the bounds of your view, it will always be 0,0. Instead, you should look at its frame coordinates. I hope this helps you in figuring out the problem.


No, there's no general mechanism for preventing changes to a view. If the view in question is your own UIView subclass, you can of course override the methods that modify the view and effectively prevent changes that way. That'd be a lot of work, however, and I don't think the result would be worth the effort; you'll be much better off finding the real problem and fixing it. It's always easier and better to work with the framework and not against it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号