Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Random crash on presenting formsheet over MGSplitViewController

I am using MGSplitViewController in my application. From the one viewcontroller, On a button click, I have navigated control to these two methods where Formsheet will open with the background of MGSplitViewController (showing Master and Detail Views.)

These methods work well and I am getting the required result, but after many operations, the app crashes over this point without printing any log. Can anyone suggest me some solution?

-(void)launchSplitViewWithFormSheet :(MGSplitViewController *)mGSplitViewController
{
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:mGSplitViewController];
    [self.baseNavigationController setViewControllers:[NSArray arrayWithObject:navController]]; 
    [self openFormSheet:mGSplitViewController];
}

-(void)openFormSheet:(MGSplitViewController *)mGSplitViewController
{
    DetailViewController *detailViewController = (DetailViewController *)[mGSplitViewController.viewControllers objectAtIndex:0];
    MasterViewController *masterViewController = [[MasterViewController alloc] initWithNibName:@"MasterViewController" bundle:nil];

    UINavigationController *baseNavController = [[UINavigationController alloc]initWithRootViewController:masterViewController];
    detailViewController.masterViewController = detailViewController;

    baseNavController.modalPresentationStyle = UIModalPresentationFormSheet;
    [mGSplitViewController presentModalViewController:baseNavController animated:YES];    
}
like image 371
parilogic Avatar asked Mar 23 '26 12:03

parilogic


1 Answers

I myself got the answer. Instead of

[self openFormSheet:mGSplitViewController];

I called up the function with thread using

    [self performSelectorOnMainThread:@selector(openPurpose:) withObject:mGSplitViewController waitUntilDone:YES];

and I am not getting random crash. :)

like image 91
parilogic Avatar answered Mar 26 '26 05:03

parilogic