iOS学习爬坑记录15:Error: UIView's window is not equal to another view's window
来源:互联网 发布:美国标志软件 编辑:程序博客网 时间:2024/05/21 14:47
今天在做页面跳转的时候犯了一个错误:在界面A添加了一个按钮,然后从这个button拖线Ctrl+drag到界面B,我为这个button添加了事件action,在这个action中使用performSegue方法跳转到界面B,运行的时候能够跳转,但是爆出打印:
2014-09-04 17:51:33.489 TileGame[79951:95150647] UIView: 0x7f7fe9c84600; frame = (0 0; 320 568); autoresize = W+H; layer = CALayer: 0x7f7fe9c848d0>>'s window is not equal to TileGame.GameScreen: 0x7f7fe9dc6bc0>'s view's window!
这个原因其实是不需要给那个button添加action,具体原因见http://stackoverflow.com/questions/25677447/error-uiviews-window-is-not-equal-to-another-views-window
原文摘录如下:
Error: UIView's window is not equal to another view's window
I am a beginner programmer learning swift. First post here.
Extra info but maybe unnecessary
In this app I created, the user chooses an image on the main View controller and passes it to the second view controller. There the image is broken up into pieces and those pieces are placed in separate UIImageViews. The objective is to put them in the right order by swapping images.
Everything is working fine and it runs ok in the simulator. However, I am trying to add basic animations (moving the UIImageViews) but they are not performing. I know I have the correct syntax for the animation because I tested the code in another project.
Main question
When I navigate from my main view controller to second view controller, an error immediately appears in the console. Here's what it says:
2014-09-04 17:51:33.489 TileGame[79951:95150647] UIView: 0x7f7fe9c84600; frame = (0 0; 320 568); autoresize = W+H; layer = CALayer: 0x7f7fe9c848d0>>'s window is not equal to TileGame.GameScreen: 0x7f7fe9dc6bc0>'s view's window!
I can't figure out what it means but it does not seem to be causing any problems except for impeding the animation. Any ideas??
Looks like this person had a similar error message but maybe more complicated than my app. Modal viewcontroller UI not responsive after presentViewController:animated:completion:
Here's my whole project on GitHub: https://github.com/pakalewis/Parker-Lewis-CF/tree/master/TileGame
Thanks
————You seem to have some fundamental misunderstandings of iOS programming paradigms. You have segues attached to your buttons, but you also then call performSegue in code. When you have a segue attached to a control, you don't need any code (and shouldn't have any) to cause the segue to execute. You also shouldn't go back to a previous view controller with a segue, other than an unwind segue; you're not really going back, you're creating a new instance of the controller you think you're going back to. This will cause a build up of controllers (as none will be deallocated) until your app runs out of memory.
So, you should delete the function, letsPlayButton: from MainScreen, and also get rid of it in the storyboard (the segue attached to that button is all you need).
Delete the segue you have going "back" from GameScreen to MainScreen, and change the code in backToMainScreen to this,
@IBAction func backToMainScreen(sender: AnyObject) { self.dismissViewControllerAnimated(true, completion: nil) }
- iOS学习爬坑记录15:Error: UIView's window is not equal to another view's window
- [IOS开发记录]Whose view is not in the window hierarchy 错误的解决办法
- iOS 简单的实现手机号正误的判断(Warning: Attempt to present... whose view is not in the window hierarchy!
- 处理iOS报错: Warning “attempt to present ViewController whose view is not in the window hierarchy”
- iOS - 报错 Warning: Attempt to present <xx: xx> on <xx: xx> whose view is not in the window hierarchy!
- view.WindowManager$BadTokenException: Unable to add window…is not valid; is your activity running?
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is yo
- android.view.WindowManager$BadTokenException:Unable to add window --token is not valid; is your acti
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is yo
- android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is yo
- view not attached to window manager
- View not attached to window manager
- illegalargumentexception: view not attached to window manager
- View not attached to window manager
- View not attached to window manager解决方案
- View not attached to window manager
- View not attached to window manager解决方案
- View not attached to window manager解决方案
- RUP 4+1
- Memcached 协议中文版
- java 发送邮件
- GridView内存及时释放,不需要使用软引用
- 利用pdf2swf将PDF转换成SWF
- iOS学习爬坑记录15:Error: UIView's window is not equal to another view's window
- hust 1010 The Minimum Length(KMP)
- FlexPaper实现文档在线浏览
- 集合的全排列
- mysql 语句学习网站
- spring security常用过滤器链的基本介绍
- 模拟退火算法
- 数据结构 总结
- Permutations