Question

So what I'm doing is trying to pass a MQMapView from one view controller to the next using:

MapSearchView *controller = [[MapSearchView alloc] initWithNibName:@"MapSearchView" bundle:nil mapToDisplay:map];

[self presentModalViewController:controller animated:NO];

And what I'm doing in my MapSearchView.m is overriding the init method:

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil mapToDisplay:(MQMapView*)map
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        [self setMapView:map];
    }
    return self;
}

I'm passing the MQMapView between views because I have some planned functionality that will need to be done to the map in the first view.

The issue I'm having is that once controller is assigned it gets passed to presentModalViewController and the app crashes there. I can't seem to find any reason for it. Any ideas?

Was it helpful?

Solution

The problem is that the xib file could not be found

Change this line

MapSearchView *controller = [[MapSearchView alloc] initWithNibName:@"MapSearchView" bundle:nil mapToDisplay:map];

to be

MapSearchView *controller = [[MapSearchView alloc] initWithNibName:@"MapSearchView" bundle:[NSBundle mainBundle] mapToDisplay:map];

Another thing ... Check the name of the xib file MapSearchView

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top