Problem putting a UINavigationViewController inside a callout

1393
3
07-27-2012 06:25 AM
DanielMonego
New Contributor II
I'm implementing an identification workflow that uses a UINavigationController that contains a series of UITableViews that allow the user to drill down into the data. Unfortunately, when I insert the navigation controller view into the callout, it weirdly overhangs the UITableView it contains:

[ATTACH=CONFIG]16435[/ATTACH]

As you can see, the navigation bar overhangs the top row of the table, which is difficult to see and access from under it.

I'm using the following code to put the view up:

-(void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results
{
    NSLog(@"Identify task returned with %d results.", [results count]);
    if (results && results.count > 0) 
    {
        IdentifyResultsViewController *idWindow = [[IdentifyResultsViewController alloc] init];
        idWindow.results = results;
        UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:idWindow];
        map.callout.customView = nvc.view;
        nvc.view.frame = CGRectMake(0, 0, 275, 400);
        
        [map showCalloutAtPoint:self.mapPoint];
    }
}



I've played around with setting the frame of the idWindow.view, but haven't had any luck with that. Are there any better ways to get this layout working correctly?
0 Kudos
3 Replies
PaulLohr
Occasional Contributor III
I wonder if you need to ask the UINavigationController instance for the proper size of the item you are adding to it?
0 Kudos
NimeshJarecha
Esri Regular Contributor
Just set the navigation view controller's frame before setting it as callout custom view and it should fix it. See code below...

-(void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results
{
    NSLog(@"Identify task returned with %d results.", [results count]);
    if (results && results.count > 0) 
    {
        IdentifyResultsViewController *idWindow = [[IdentifyResultsViewController alloc] init];
        idWindow.results = results;
        UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:idWindow];

        //set the frame before setting the callout custom view
        nvc.view.frame = CGRectMake(0, 0, 275, 400);
        map.callout.customView = nvc.view;

        [map showCalloutAtPoint:self.mapPoint];
    }
}


Regards,
Nimesh
0 Kudos
AaronConnolly
Occasional Contributor
Just set the navigation view controller's frame before setting it as callout custom view and it should fix it. See code below...

-(void)identifyTask:(AGSIdentifyTask *)identifyTask operation:(NSOperation *)op didExecuteWithIdentifyResults:(NSArray *)results
{
    NSLog(@"Identify task returned with %d results.", [results count]);
    if (results && results.count > 0) 
    {
        IdentifyResultsViewController *idWindow = [[IdentifyResultsViewController alloc] init];
        idWindow.results = results;
        UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:idWindow];

        //set the frame before setting the callout custom view
        nvc.view.frame = CGRectMake(0, 0, 275, 400);
        map.callout.customView = nvc.view;

        [map showCalloutAtPoint:self.mapPoint];
    }
}


Regards,
Nimesh


Is this a bug? Why does this happen with UINavigationController but not with a stock UIViewController? I also noticed that if you set the callout's customView to a generic UIViewController, then some time later set it to a UINavigationController you don't see this issue with the nav bar.
0 Kudos