First of all, I wonder what version of quick use is used.
self.view is optional in 1.2 so you should enter: self.view?.addSubview() if you are targeting swift 1.2
I tried in swift 1.2 to make a simple application
class GameScene: SKScene { let subview = UIView() override func didMoveToView(view: SKView) { subview.frame = CGRectMake(0, 0, 100, 100) subview.backgroundColor = SKColor.orangeColor() self.view?.addSubview(subview) } override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) { removeContainerView() } func removeContainerView() { subview.removeFromSuperview() } }
The above code works very well. I can think of several reasons why your gaze is not removed.
- Are you sure that
removeContainerView indeed called. Try making a breakpoint to see if it's called - If you configured your SKView in code, something might be wrong.
- Your subtask is freed or something happens.
To fully debug your problem, we need to see another code.
We need:
- Announce your spy
- All functions calling removeContainerView ()
Even better would be pastebin your SKScene class.
source share