- objective-c - iOS 5 : Can you override UIAppearance customisations in specific classes?
- iphone - 如何将 CGFontRef 转换为 UIFont?
- ios - 以编程方式关闭标记的信息窗口 google maps iOS
- ios - Xcode 5 - 尝试验证存档时出现 "No application records were found"
我有一个 map View ,我根据 popovercontroller
中的开关添加和删除 annotations
。当我触摸 popover
外部时,它会正确关闭并调用 delegate
方法 popoverControllerDidDismissPopover:
我遇到的问题是,当我切换在 popover
中切换(在 popover View 中触摸),如果我从 map 中删除 annotations
它的行为正确并且 popover 保持可见但如果我添加 annotations
到 map View ,然后 popover
消失并且 delegate
方法不被调用。以前有人遇到过这种行为吗?
开关的 on 和 off 代码之间的唯一区别是,一个从数组中删除 annotations
,而另一个添加 annotations
。这只是在将 annotations
添加到 map View 时出现的问题。如有任何帮助或建议,我们将不胜感激。
这是 popover
的显示方式:
-(IBAction)toggleMapFiltersView:(id)sender
{
LayerPopoverViewController *popOverViewController = [[LayerPopoverViewController alloc] init];
[popOverViewController setDelegate:self];
[popOverViewController setBranchesShowing:branchesShowing];
[popOverViewController setSchoolsShowing:schoolsShowing];
[layersButton setSelected:YES];
popoverController = [[UIPopoverController alloc] initWithContentViewController:popOverViewController];
[popoverController setDelegate:self];
[popOverViewController release];
[popoverController presentPopoverFromRect:layersButton.frame
inView:[self view]
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
这是从弹出 View 调用的方法:
-(IBAction)toggleSchools:(id)sender
{
if ([self.delegate respondsToSelector:@selector(didChangeSchoolsDisplaySettingWithVisible:)])
{
if ([schoolsSwitch isOn])
{
[self.delegate didChangeSchoolsDisplaySettingWithVisible:YES];
self.schoolsShowing = YES;
}
else
{
[self.delegate didChangeSchoolsDisplaySettingWithVisible:NO];
self.schoolsShowing = NO;
}
}
}
这是它所指的方法:
-(void)didChangeSchoolsDisplaySettingWithVisible:(BOOL)visible
{
if (visible == YES)
{
schoolsShowing = YES;
if (self.schoolArray != nil && [self.schoolArray count] > 0)
{
for (MySchool *school in self.schoolArray)
{
[mapView addAnnotation:school];
}
}
}
else
{
schoolsShowing = NO;
for (id<MKAnnotation> annotation in mapView.annotations)
{
if ([annotation isKindOfClass:[MySchool class]])
{
[mapView removeAnnotation:annotation];
}
}
}
}
最佳答案
为什么首先使用弹出窗口?您可以更轻松地控制自定义 View 。
您可以创建一个自定义的 popupView,并将其放置在您喜欢的坐标之上。弹出窗口有一个关闭按钮,并委托(delegate)调用此操作。
这是一些代码(在这个例子中,坐标来自一个标记,而 mapView 是谷歌的)。您还必须将坐标转换为 CGPoint。
UIAnnotationView *annotation = [[UIAnnotationView alloc] initWithFrame:CGRectMake(0,0,100,100)];
annotation.delegate = self;
annotation.tag = 101;
CGPoint point = [mapView.projection pointForCoordinate:marker.position];
annotation.origin = CGPointMake(point.x - annotation.width / 2, point.y - annotation.height - MARKER_DEFAULT_SIZE);
[mapView addSubview:annotation];
UIAnnotaionView closeButtonClicked 委托(delegate):
- (void)annotationViewCloseButtonClicked:(UIAnnotationView *)annotationView
{
[[_mapView viewWithTag:101] removeFromSuperview];
}
要在触摸 map 中的其他点时关闭弹出 View ,请覆盖此委托(delegate):
- (void)mapView:(GMSMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate
{
[[_mapView viewWithTag:101] removeFromSuperview];
}
关于iphone - UIPopoverController 在没有委托(delegate)调用的情况下解散,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10341579/
我试图通过 unionSpatialPolygons 溶解内部多边形来生成六边形 map 的轮廓。或 aggregate职能。我得到了不溶解的杂散十六进制......一个显示问题的虚拟示例: # gr
我使用 AVPlayerViewController 在我的应用中播放短视频。 如果在用户在我的应用中播放视频之前有一个应用在后台播放音频,我希望在我的视频播放器关闭后恢复另一个应用的后台音频播放。我
我有三个 Controller 与 segues 相连。 Controller 一是 MyNotif, Controller 二是 AddNotif, Controller 三是 SelectInte
在我学习 Swift 3 和 Xcode 8 的过程中,我现在感到困惑或不知道何时使用正确的切换方法。要取消你解雇,返回你回去但后退按钮可以解雇吗? 哪一个是内存使用方面的最佳实践? @IBActio
我一直在尝试使用 Storyboards 关闭模态,但从阅读旧的 beta 版本来看,这些模态似乎已损坏。我尝试添加 header 以允许我从 Obj-C 端放松,但仍然没有。 这是我的swift文件
我是一名优秀的程序员,十分优秀!