【问题标题】:Tab Bar not showing up in the simulator标签栏未显示在模拟器中
【发布时间】:2012-10-31 03:13:01
【问题描述】:

在界面生成器中,我的标签栏出现了,但它不会出现在我的模拟器中。我试过重新定位它并在界面生成器中弄乱一些东西,但它仍然没有出现。为什么是这样? 这是编码

#导入 #导入

@interface mapview : UIViewController {

 MKMapView *mapView; 


}


-(IBAction)setMap:(id)sender;

-(IBAction)pushBack;

-(IBAction)findmyass:(id)sender;








@end

#import "mapview.h"
#import "NewClass.h"


@implementation mapview




-(void)viewDidLoad {
[super viewDidLoad];

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

[self.view addSubview:mapView];  
[NSThread detachNewThreadSelector:@selector(displayMap) toTarget:self withObject:nil];  



[mapView setMapType:MKMapTypeStandard];
[mapView setZoomEnabled:YES];
[mapView setScrollEnabled:YES];

MKCoordinateRegion region = { {0.0, 0.0 }, {0.0, 0.0 } };
region.center.latitude = 39.956907;
region.center.longitude = -75.610229;
region.span.longitudeDelta = 0.01f;
region.span.latitudeDelta = 0.01f;
[mapView setRegion:region animated:YES];


NewClass *ann = [[NewClass alloc] init];
ann.title = @"Vigil Location of Chester County ";
ann.subtitle = @"8 S. Wayne St. West Chester, PA 19382";
ann.coordinate = region.center;
[mapView addAnnotation:ann];

-(void)displayMap {  
MKCoordinateRegion region;  
MKCoordinateSpan span;  
span.latitudeDelta=0.2;  
span.longitudeDelta=0.2;  

CLLocationCoordinate2D location;  
location.latitude = -35;  
location.longitude = 146.2381;  
region.span=span;  
region.center=location;  

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

- (void)dealloc {  
[mapView release];  
[super dealloc];  
}  




/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a        
- (void)viewDidLoad {
[super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:    (UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];

// Release any cached data, images, etc that aren't in use.
 }

 - (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
 }






-(IBAction)pushBack {

[self dismissModalViewControllerAnimated:YES];
 }

 -(IBAction)findmyass:(id)sender {

mapView.showsUserLocation = YES;

 } 

 @end

【问题讨论】:

    标签: xcode mapkit tabbar


    【解决方案1】:

    我想知道您的 mapView 是否覆盖了标签栏,因为您正在使用与整个视图 (self.view.bounds) 相同的框架初始化 mapView。

    如果这是问题,请尝试

    CGRect frame = self.view.bounds;
    frame.size.height = frame.size.height - 40;
    mapView = [[MKMapView alloc] initWithFrame:frame]; 
    

    而不是

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

    这应该告诉你这是否是你的问题。如果是这样,您可能应该获得对标签栏的引用并减去它的高度,而不是硬编码的“40”。

    【讨论】:

    • 效果很好,谢谢。查找用户位置现在不起作用吗?有什么建议吗?
    • 很高兴工作。请点击“检查”以接受答案。
    猜你喜欢
    • 2015-10-05
    • 2016-11-03
    • 1970-01-01
    • 2021-12-26
    • 2015-11-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多