我正在创建一个MKMapView应用程序,需要在plist中保存一些MKMapRect类型变量,以便在需要时引用它们.
我知道MKMapRect有MKMapPoint origin和MKMapSize size.并且它们每个都有2个可以保存的双值,nsnumber但保存它们似乎是很多工作,最重要的是我必须读回值并将它们转换为MKMapRect变量.
所以我的问题是,有没有简单的方法来存储MKMapRect并从plist中回溯它.
谢谢,
罗宾.
我希望有一些annotationView图像显示在其他图像之上,因此它们更容易看到.有没有办法设定订单?
我以为我会尝试类似的东西
[theMap addAnnotations:arrayOfLessImportantItems];
[theMap addAnnotations:arrayOfMoreImportantItems];
Run Code Online (Sandbox Code Playgroud)
但是在尝试此操作后很明显,委托方法MKMapViewDelegate mapView:viewForAnnotation在放下它们时不会观察到任何特定的顺序.(由于注释视图来自池,因此当地图在屏幕上移动时,委托必须添加和删除注释视图图像.)
但我确实有一些我希望更容易看到的项目,并且它们被埋在不太重要的地图引脚后面.有办法克服这个问题吗?
我的MapViewController中有以下方法:
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation {
MKAnnotationView *annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier:@"MapVC"];
if (!annotationView) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"MapVC"];
annotationView.canShowCallout = YES;
annotationView.leftCalloutAccessoryView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
// could put a rightCalloutAccessoryView here
} else {
annotationView.annotation = annotation;
[(UIImageView *)annotationView.leftCalloutAccessoryView setImage:nil];
}
return annotationView;
}
Run Code Online (Sandbox Code Playgroud)
我相信它设置正确,但是当我的地图正确地显示我的带有标题和副标题的注释时,但它们没有显示详细信息披露按钮,我错过了什么吗?
另一件事是,在调试时,从不调用此方法,但注释视图显示标题和副标题.
我有一个功能可以缩放放在地图上的注释的一半,以及用户的位置,这样两者都可以在屏幕上看到.是否有注释方法显示其"内容",即模拟按下它?一旦放大,它就会很开放.
提前致谢.
我有一个CLLocation从文件中解析的对象数组.我想模拟用户沿着那条路线移动,我已经实现了这个:
for (CLLocation *loc in simulatedLocs) {
[self moveUser:loc];
sleep(1);
}
Run Code Online (Sandbox Code Playgroud)
这是循环中调用的方法:
- (void)moveUser:(CLLocation*)newLoc
{
CLLocationCoordinate2D coords;
coords.latitude = newLoc.coordinate.latitude;
coords.longitude = newLoc.coordinate.longitude;
CustomAnnotation *annotation = [[CustomAnnotation alloc] initWithCoordinate:coords];
annotation.title = @"User";
// To remove the previous location icon
NSArray *existingpoints = self.mapView.annotations;
if ([existingpoints count] > 0) {
for (CustomAnnotation *annotation in existingpoints) {
if ([annotation.title isEqualToString:@"User"]) {
[self.mapView removeAnnotation:annotation];
break;
}
}
}
MKCoordinateRegion region = { coords, {0.1, 0.1} };
[self.mapView setRegion:region animated:NO];
[self.mapView addAnnotation: …Run Code Online (Sandbox Code Playgroud) 有没有办法防止/限制缩放.我想让用户缩放到我设定的固定限制.可以选择:
- (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated
Run Code Online (Sandbox Code Playgroud)
令人厌恶,因为首先你放大,当你完成它会自动缩小.目标是在用户到达zoomlimit时停止缩放,即使他继续手势.
从iOS6中的MKMapView派生并不是有目的的,因为没有要覆盖的scrollView方法:(
还有其他想法吗?
我正在开发一个小项目,在地图上显示7种不同类型的注释.我的注释取自数组中的url结果,我使用JSON解析它.我有很多注释,一旦地图加载,一切看起来都很好.放大和缩小后,引脚图像由于某种原因改变为错误的引脚图像(特定图像,没有线索原因).
我相信我在这里遗失了一些东西......请你帮忙:)?
这是我的代码的一部分,如果您需要它,请告诉我:
-(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation{
static NSString *identifier;
if(_mapView.tag==1){identifier = @"TurbulencePin";}
if(_mapView.tag==2){identifier = @"IcingPin";}
if(_mapView.tag==3){identifier = @"WindsPin";}
if(_mapView.tag==4){identifier = @"TemperaturePin";}
if(_mapView.tag==5){identifier = @"CloudsPin";}
if(_mapView.tag==6){identifier = @"VisibilityPin";}
if(_mapView.tag==7){identifier = @"MultiplePin";}
if ([annotation isKindOfClass:[MKUserLocation class]])
return nil;
if ([annotation isKindOfClass:[Annotation class]]) {
CustomAnnotationView* annotationView = (CustomAnnotationView*)[mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
annotationView = nil;
if (annotationView == nil) {
annotationView = [[CustomAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:identifier];
annotationView.enabled = YES;
annotationView.canShowCallout = YES;
UIImage *img = [UIImage imageNamed:[NSString stringWithFormat:@"%@.png",identifier]];
annotationView.image = img;
}
else
{
annotationView.annotation …Run Code Online (Sandbox Code Playgroud) 我有一个带导航控制器和标签栏控制器的ViewController.此ViewController有2个按钮,用于切换滚动视图和地图视图的可见性.最重要的是让这两个按钮始终显示在同一个地方,无论方向或恰好可见的视图.
我遇到的问题是MapView的大小不正确.如果我只是从self.view.bounds给它一个框架它位于导航栏/标签栏下 - 基本上占据了整个屏幕.这会抛弃我的切换按钮的位置.
我注意到我的ScrollView也是这样(使用背景颜色和半透明导航栏),但子视图在其上的位置保持在可见区域内(导航栏和标签栏之间).因此,当我添加切换按钮时,它们会显示在正确的位置.
当我按下切换按钮时,我只是将按钮的父视图重新分配给现在显示的视图(ScrollView或MapView).这总是适用于滚动视图,但由于定位,它们最终会在显示MapView时进入导航栏下方.
我已经尝试手动创建MapView的框架,但我得到奇怪的结果.我用它作为框架:
CGRect mapFrame = CGRectMake(
0,
(self.navigationController.navigationBar.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height),
self.view.frame.size.width,
(
self.view.frame.size.height
- (self.navigationController.navigationBar.frame.size.height + [UIApplication sharedApplication].statusBarFrame.size.height + self.tabBarController.tabBar.frame.size.height)
)
);
Run Code Online (Sandbox Code Playgroud)
然后我设置自动调整大小的面具
[self.mapView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin];
Run Code Online (Sandbox Code Playgroud)
但有了这个,如果我以横向模式进入视图控制器 - MapView不在屏幕上.如果我进入纵向模式然后旋转到横向,则上边距关闭但大约10个点,因此它仍然位于导航栏下方(并且在标签栏和地图视图底部之间有可见边距).
如何使MapView子视图仅显示在可见区域内,就像ScrollView一样?如果地图本身位于导航栏/标签栏下方,我不介意
我正在使用MKMapView在iOS模拟器中获得看起来随机发生的崩溃.它不是由任何用户操作触发的,它只是无中生有.我得到以下堆栈跟踪:
<_NSCallStackArray 0x2d9762b0>(
0 ??? 0x137d69bd 0x0 + 326986173,
1 Foundation 0x03ca3b0a -[NSObject(NSKeyValueCoding) valueForUndefinedKey:] + 282,
2 Foundation 0x03c10b61 _NSGetUsingKeyValueGetter + 81,
3 Foundation 0x03c1019b -[NSObject(NSKeyValueCoding) valueForKey:] + 260,
4 AccessibilityUtilities 0x11ad1a3f -[NSObject(UIAccessibilitySafeCategory) safeValueForKey:] + 43,
5 MapKitFramework 0x12090aa4 -[MKBasicMapViewAccessibility(SafeCategory) accessibilityContainerElements] + 91,
6 UIAccessibility 0x11fc7149 -[NSObject(AXPrivCategory) accessibilityElementCount] + 34,
7 UIAccessibility 0x11fc751f -[NSObject(AXPrivCategory) _accessibilityHasOrderedChildren] + 59,
8 UIKit 0x11ebb388 -[UIViewAccessibility(SafeCategory) _accessibilitySubviewsForGettingElementsIncludingContainers:includingOpaqueElementProviders:] + 2269,
9 UIKit 0x11ebba96 -[UIViewAccessibility(SafeCategory) _accessibilityElementsInContainer:topLevel:includeKB:includeOpaqueElementProviders:] + 486,
10 UIKit 0x11eba12f -[UIViewAccessibility(SafeCategory) _accessibilityElementsInContainer:topLevel:includeKB:] + 64,
11 UIKit …Run Code Online (Sandbox Code Playgroud) 我正在开发这样一个应用程序执行以下操作的项目:
viewController按"开始"按钮转到下一个现在,我在这里监视一个区域,然后再监视另一个区域.所以数字实际上就是一个.但是我知道一个应用程序可以通过"区域监控"监控的区域的最大数量是15.现在我的问题是在这种情况下我应该处理这个最大数量的区域问题吗?如果是,那怎么样?
我想补充的另一件事是,它有一些解决方案,它只适用于iOS 6及更早版本.所以请根据用户在iOS7中的当前位置,通过"RegionMonitoring"监控处理"区域"数量的解决方案,让我知道.
如果能够给出答案或任何建议来完成我的应用程序所需要求,我将感到非常高兴.
mapkit ×10
ios ×7
mkmapview ×4
iphone ×3
objective-c ×3
mkannotation ×2
annotations ×1
geofencing ×1
ios5 ×1
ios6 ×1
map ×1
plist ×1
uibutton ×1
xcode ×1