UA-17470720-3

Jump to content


Photo
- - - - -

iOS7 App Crashes With Container Views and Embedded TableViews and MKMapView


  • Please log in to reply
2 replies to this topic

#1 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 27 October 2013 - 03:17 PM

Greetings Programs!

 

This issue does not occur when using XCode 4.6 and iOS6 but the minute I change it to iOS7, it pops up. It probably has to do with the number of views I need to load and the time each one needs and the way iOS7 handles things BUT it ONLY occurs (so far anyways) when I place a MKMapView in the same view.

 

I have this:

 

Tab Bar Controller

    +--- Navigation Controller

                         +--- View Controller

                                     +--- Container View1

                                                 +--- SCSearchViewController1

                                                                +--- Search Bar

                                                                +--- TableView

                                     +--- Container View2

                                                 +--- SCSearchViewController2

                                                                +--- MKMapView

                                     +--- Container View3

                                                 +--- SCSearchViewController3

                                                                +--- Search Bar

                                                                +--- TableView

                                     +--- Container View4

                                                 +--- SCSearchViewController4

                                                                +--- Search Bar

                                                                +--- TableView

 

 

Now, it didn't matter if the MKMapView was in the container view or the view controller, the app would crash whenever the view would load; it would sometimes give a message about an invalid selector or nothing.

 

I found that it was crashing at that point when I replaced the default tableViewModel with the new objectsModel:

self.tableViewModel = objectsModel;

 

To solve the problem of crashing, I set a short delay before assigning it.

double delayInSeconds = 0.1;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
	weak_self.tableViewModel = objectsModel;
});

 

Any thoughts on other solutions?

 

Wg
 

 


P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)


#2 Dave Guerin

Dave Guerin

    Forum Master

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 545 posts
  • LocationIreland
Reputation: 137
Popular

Posted 27 October 2013 - 03:39 PM

Hi wizgod,

 

Are both 

 

self.tableViewModel = objectsModel;

 

and the MKMapView added in viewDidLoad: ?

 

Try them in viewWillAppear: or even viewDidAppear:


  • wizgod likes this
Cheers,

Dave

www.dgapps.ie

#3 wizgod

wizgod

    I'm what you guys call a User

  • STV 5.0 Pro
  • PipPipPipPipPipPipPip
  • 575 posts
  • LocationThe Grid
Reputation: 149
Popular

Posted 27 October 2013 - 06:51 PM

Thanks for the insight Dave!

 

They're all in the viewDidLoad and I previously had the same result in viewWillAppear but didn't think about viewDidAppear. I moved the code to the viewDidAppear for the tableviews and was able to remove the delay block without receiving any error.

 

Thanks again!

 

Wg


P.S. I love Swift... talk Swift.. Never too old school to learn yet another programming language. LOL! ;-)





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users