简体   繁体   English

在子视图之间切换时出现问题(iOS开发)

[英]Problem when changing between Subviews (iOS Developement)

I am developing for iOS for about 5 to 6 months now. 我现在为iOS开发大约5至6个月。 Right now I am trying to implement a Face Detection Algorithm which marks faces on an UIImage which i take with help from the AVFoundation Framework. 现在,我正在尝试实现一种面部检测算法,该算法在UIImage上标记人脸,这是我在AVFoundation框架的帮助下采取的。

Well, it all works (almost) fine. 好吧,这一切(几乎)都可以。 During the programming stages i had simple buttons with which i could do all the steps one at a time. 在编程阶段,我有简单的按钮,可以一次完成所有步骤。 Everything worked great. 一切都很好。

Now i packed everything into one button click, but even after 2-3 minutes nothing showed up. 现在,我将所有内容打包到一个按钮中,但是即使经过2-3分钟也没有任何显示。 I played around a little with NSLog outputs to mark the time when every step was completed and the Algorithm and everything was successful, but the View still would not change to show the Image which i packed into the UIImageView as a subview of the other View. 我在NSLog输出中花了一些时间来标记完成每个步骤以及算法和所有操作成功的时间,但是View仍然不会改变以显示我打包到UIImageView中的Image作为另一个View的子视图。

Funny thing is, when i get the NSLog Message i can click on the place on the screen where other buttons are (as i placed them in the Interface Builder) and those buttons actually react to my interaction though nothing is shown!? 有趣的是,当我收到NSLog消息时,我可以单击屏幕上其他按钮所在的位置(就像我将它们放置在Interface Builder中一样),这些按钮实际上对我的交互有反应,尽管什么也没显示!

I usually transit between UIViews by setting the alpha Value to 0.0 and 1.0. 我通常通过将alpha值设置为0.0和1.0在UIView之间进行转换。 Then I tried to transit with [[viewController view] bringSubviewToFront:subview]; 然后,我尝试使用[[viewController view]带子SubviewToFront:subview];进行过渡; but that didn't help! 但这没有帮助!

Anyone knows where the problem might be? 有人知道问题可能在哪里吗?

Best Regards! 最好的祝福!

It could be that your are making changes to views on a background thread. 可能是您正在更改后台线程上的视图。 Try performing the changes on the main thread. 尝试在主线程上执行更改。

It could be that the z-ordering is not what you are expecting if you're switching between subviews. 如果要在子视图之间切换,则z排序可能不是您期望的。 If you have a pointer to the UIView that isn't showing up, try using the exchangeSubviewAtIndex:withSubviewAtIndex: method of the parent view to make sure that the desired one is on top. 如果您有未显示的UIView指针,请尝试使用父视图的exchangeSubviewAtIndex:withSubviewAtIndex:方法,以确保所需的视图位于顶部。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM