uchicago-mobi / MPCS51030-2017-Winter-Forum

7 stars 0 forks source link

Different behavior between simulator and my iphone #120

Closed bygong closed 7 years ago

bygong commented 7 years ago

I had done my duckduckgo, but something weird after I tried mess with my app and iPhone 6:

1.On simulator, the app launches with only calling "viewdidload" of masterviewController, and only shows masterview at first correctly. On my iphone, the app also calls "viewdidload" of detailviewController after masterviewController and shows the detailview at first.

  1. The button back to masterview is missing. So I lost the way back to masterview. I'm not sure whether it is because the splitview mistakenly collapsed or something wrong with the initialization order.

Everything works fine on simulator. My iPhone WAS once running it correctly, after I attemped its limitation like unplug it while running or delete the app while debugging, it finally broke up :( don't do that. Tried everything like reboot or reinstall. Would you please see what you can do or just if it runs correctly on your phone?

Follow-up: I'm now pretty sure they are because the app incorrectly collapses on my iPhone.

tabinks commented 7 years ago

I will take a look at it. One quick thing to do is to log a statement for all the life cycle functions (eg. viewDidLoad, etc.) for each view controller and watch how the views are initiated.

Here is an example of a function that prints the class, file and function name when called:

func logFunctionName(file:String = #file, fnc:String = #function, line:(Int)=#line) {
    if let className = file.components(separatedBy: "/").last?.components(separatedBy: ".") {
        print("\(className[0]):\(fnc):\(line)")
    }
}
bygong commented 7 years ago

Yes I did that, and my iPhone behaves just like an portrait IPad: Load Masterview-> load Detailview-> detailview appear, which should've been only load masterview -> masterview appear on iphone