Resolved UIViewController loading, shows up in view debugger, but not on device

Discussion in 'iOS Programming' started by moonman239, Oct 28, 2015.

  1. moonman239, Oct 28, 2015
    Last edited: Nov 4, 2015

    moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    I have a bit of a problem, for which I can't find a solution.

    I have a view controller, which we'll call Bob. Bob is launched via a push segue from another view controller. Bob used to appear on the device, but then I changed the "collectionView:cellForItemAtIndexPath:" method and did a rebuild - at some point after that, Bob started appearing only in my view debugger. I've verified that viewWillAppear gets called, but neither viewDidAppear nor collectionView:cellForItemAtIndexPath do. Interestingly, my CPU stat sits at around 100%.

    Solution: Pause the app with the debugger to check if the app is in a loop.
     
  2. Mascots macrumors 65816

    Mascots

    Joined:
    Sep 5, 2009
    #2
    Is the entire app locked up when this happens? And is this CPU usage of 100% localized to your phone or are you running it in the simulator?

    From what you've said, it sounds like something in your collectionView:cellForItemAtIndexPath: or viewWillAppear: is blocking other processes from continuing, something like maybe an infinite loop?
     
  3. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #3
    Well, there's nothing in viewWillAppear (I just overrode it to see why my app is acting the way it is). Also, in cellForItemAtIndexPath, there's no loop of any kind prior to the breakpoint.

    There's only one thing the user is supposed to do in the view controller prior to Bob, so I have no visible UIControl other than the button that takes the user to Bob. However, the button appears stuck in the "tapped" state.
     
  4. Mascots macrumors 65816

    Mascots

    Joined:
    Sep 5, 2009
    #4
    What is before your breakpoint in collectionView:cellForItemAtIndexPath:? Seeing that may be helpful.

    The only other things I would suggest would be:
    1. Breaking and replacing your segues in Storyboard (to catch unwanted or weird ones)
    2. Instead of linking a segue from the cell directly, link it between the view controllers and use perfomSegue: in collectionView:cellForItemAtIndexPath: to see if you have the same result.
    3. Using instantiateViewControllerWithIdentifier(_: ) to create the view and manually pushing via the navigation controller pointer

    At the very least, it may help you find out where the issue is cropping from.
     
  5. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #5
    OK, thanks, but you misunderstood me a little bit. What's triggering the segue is not a cell, but a button. In fact, the view controller causing the segue doesn't have a collection view or table view. Bob is the one with the collection view.
     
  6. Mascots macrumors 65816

    Mascots

    Joined:
    Sep 5, 2009
    #6
    Oh! I did misread, but the same logic applies as far as changing around the method that you are pushing Bob. Does it work switching between segue and using a navigation controller directly? Are you able to push in another, blank, view?

    I know this is kind of verbose, but since I don't have access to any code, all I can do is hint towards where the problem may live.
     
  7. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #7
    OK, so I pushed the view controller to the navigation controller instead, and still no luck. Could it be the iPad version? This one is 8.2 and I think I'm using 9 SDK.

    Edit: I could see if it works on 9.0. If so, I'm just going to forget about iOS 8.
     
  8. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #8
    Did you design the view controller in the size class any any or regular regular?
     
  9. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #9
    I don't know.
     
  10. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #10
    In interface builder (the storyboard editor), look at the bottom bar just above the debugger. In the middle of it, it should have two values. Tell me the two values that show up. Screen Shot 2015-10-29 at 10.50.52 AM.png
     
  11. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #11
    According to the File Inspector, I'm not using any size classes.
     
  12. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #12
    What does that bottom bar say? Post a screenshot.
     
  13. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #13
    no-size-classes.png
     
  14. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #14
    Thats the bar, just show me the middle part like on mine where it says wAny hAny
     
  15. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #15
    I don't see a blue bar.
     
  16. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #16
    Not a blue bar, but text next to it. Send me a Screen shot of your whole window. Are you on the latest Xcode?
     
  17. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #17
    Yes, and what I've posted above is all I see where it appears there "should" be text saying something like "wAny hAny"
     
  18. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #18
    Maybe you have an old interface builder document. Try making a new one and creating a random view controller and connecting that one to your view controller code. See if it will load by placing colored views. Then report back. If that fixes it, its an interface builder issue. If not, its a code issue.
     
  19. JWalker1995 macrumors regular

    Joined:
    Mar 5, 2011
    #19
    If you don't have size classes enabled you won't see the wAny hAny FYI
     
  20. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #20
    True. But if you did and you designed your views in regular regular, they won't show up on iPhone and vis versa
     
  21. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #21
    So, it looks like it could be Interface Builder. It worked after creating a new storyboard and wiring up some test data (had to do that because the previous VC passes along data Bob needs).
     
  22. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #22
    I think there's an option to upgrade the storyboard from the right toolbar.
     
  23. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #23
    It may already have been upgraded. I see a "Use Size Classes" checkmark in File Inspector.
    Edit: Also, "Opens In" is set to "Default (7.0)".
     
  24. iphonedude2008 macrumors 65816

    iphonedude2008

    Joined:
    Nov 7, 2009
    Location:
    Irvine, CA
    #24
    Ok then you are updated. If it's not too much work, I would just recreate the view controllers in a new storyboard.
     
  25. moonman239, Oct 31, 2015
    Last edited: Oct 31, 2015

    moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #25
    Just to clarify, though, you wanted me to create a storyboard with just Bob and no segues, right?

    Edit: Thanks for lending a hand!
     

Share This Page