开发者

iPhone : Top Navigation bar push the Google logo down the screen

I am new to iPhone development, please suggest the right way to rectify the below problem.

I am displaying the Google Map as below :

iPhone : Top Navigation bar push the Google logo down the screen

Now the problem is the Top Navigation bar pushes the Google logo on Map below screen and hence it is not visible, when I hide the Navigation bar, I can see the Google logo as below

iPhone : Top Navigation bar push the Google logo down the screen

Code Reference :

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.navigationController setNavigationBarHidden:YES animated:NO];

    mapView.showsUserLocation=TRUE;
    self.title =@"Map View";
    mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
    mapView.showsUserLocation=TRUE;
    mapView.mapType = MKMapTypeStandard;
    mapView.delegate=self;




    /*Region and Zoom*/
    MKCoordinateRegion region;
    MKCoordinateSpan span;
    span.latitudeDelta = 0.2;
    span.longitudeDelta = 0.2;

    CLLocationCoordinate2D location=mapView.userLocation.coordinate;
    AppDelegate *appdelegate=(AppDelegate *)[[UIApplication sharedApplication]delegate];    

    location.latitude = [appdelegate.RDLat doubleValue];
    location.longitude = [appdelegate.RDLng doubleValue];

    region.span=span;
    region.center=location;


    [mapView setRegion:region animated:TRUE];
    [mapView regionThatFits:region];


    ParkPlaceMark *placemark=[[ParkPlaceMark alloc] initWithCoordinate:location title:appdelegate.RestAddress];
    [mapView addAnnotation:placemark];

    [self.view insertSubview:mapView atIndex:0];

}

Now Please suggest me how to show Navigation bar without pushing the Google 开发者_开发技巧map below.

Any help highly appriciated


Just change below line

mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];

To

mapView = [[MKMapView alloc] initWithFrame:CGRectMake(self.view.frame.origin.x,44,self.view.frame.size.width,self.view.frame.size.height-44)];

And It will work as charm. Let me know if it is not.


The problem is the size of your view : it's too big. If you built the view using the interface builder, you have to set the top bar property of your UIView to Navigation Bar in the properties panel. This should automatically resize your view. Make sure your map view is resized as well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜