1

I have two UIViewController. One is ViewController, and another is GameplayViewController.

ViewController will execute

let gameplayViewCtrl = GameplayViewController() self.presentViewController(gameplayViewCtrl, animated: true, completion: nil)

in viewDidAppear() function. So it shows then load another UIViewController.

GameplayViewController has UICollectionView as its member. It extends/conforms to UIViewController, UICollectionViewDelegate, UICollectionViewDataSource. I've linked delegate, datasource, and UICollectionView variable as @IBOutlet properly in storyboard.

With above setup, I tested it. It shows white screen for a sec, then shows black screen. The cells in UICollectionView in GameplayViewController are never get loaded (no call in code checked via breakpoint). But if I changed the entry point (an arrow in storyboard) to point at GameplayViewController, then it loads properly and show all data in cells. Things work fine.

What's the problem here? I guess it's about event chain that never get caught in non-default UIViewController.

FYI: I do this in xcode 6 beta 3

Updated

I did some more research, and found out there're at least two possible ways to do this. One is my approach, and another is to use segue.

Segue works, you can find how to do it How do I use performSegueWithIdentifier: sender:?. I tested it.

I also tested to switch from GameplayViewController to ViewController (reverse from my original test). It showed black screen similar to the first test. But it should show white screen as for ViewController, it has white background color. This triggers me to think that something's wrong creeping inside.

For now, I use segue approach. But I still want to know why self.presentViewController() won't do the job for us, and it shows black screen and nothing called or happened.

Community
  • 1
  • 1
haxpor
  • 2,431
  • 3
  • 27
  • 46
  • @rmaddy Thanks for removing unnecessary tag. – haxpor Jul 13 '14 at 16:08
  • Check both your controllers and see if you have overridden any of your appearance methods without calling super? – Essan Parto Jul 13 '14 at 17:41
  • @E.Parto Checked it, nope. Already called super. – haxpor Jul 13 '14 at 17:54
  • Could you please provide some more code? – gotnull Jul 14 '14 at 05:13
  • @gotnull I think there're nothing more. For GameplayViewController, the class conforms to UICollectionViewDelegate, and UICollectionViewDataSource, which it works just fine. Even if I start from GameplayViewController (show data just fine), then switch to ViewController, it still shows black screen the same. See my update of the question. – haxpor Jul 14 '14 at 09:21

0 Answers0