Jan*_*ann 2 sdk frame mapkit ipad uipopovercontroller
我试图让一个popover出现在地图工具包注释点但是在注释视图属性中找不到"rect"来使用调用uipopovercontroller的rect方法.如果在地图套件上给出注释,如何找到合适的"框架"?
为了给保罗提供更多信息,这是我的尝试:我已经使用过:
- (void)mapView:(MKMapView *)mapView2 annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control{
NSLog(@"annotationView...");
MyGizmoClass *myGizmoClass= [MyGizmoClass sharedManager];
int choice = 0;
for (NSMutableDictionary *locationDictionary in [myGizmoClass searchResultsForResortLocation])
{
if([view.annotation.title isEqualToString:[locationDictionary objectForKey:@"name"]])
{
DetailViewTableStyleController *controller = [[DetailViewTableStyleController alloc] initWithlocationData:[[myGizmoClass searchResultsForResortLocation] objectAtIndex:choice] nibName:@"DetailViewTableStyle" bundle:[NSBundle mainBundle]];
controller.categoryCode = [locationDictionary objectForKey:@"category_code"] ;
//create a popover controller
popoverControllerDetail = [[UIPopoverController alloc] initWithContentViewController:controller];
// set contentsize
[popoverControllerDetail setPopoverContentSize:CGSizeMake(320,480)];
//present the popover view non-modal
[popoverControllerDetail presentPopoverFromRect:view.rightCalloutAccessoryView.frame inView:mapView2 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[controller release];
break;
}
choice = choice + 1;
}
}
Run Code Online (Sandbox Code Playgroud)
而且......我在mapview边缘的左上角有一个popover.
谁能告诉我为什么?我试图让它出现在pin/annotationview附近.
好的,
以下是迄今为止我发现的唯一解决方法:
CGPoint annotationPoint = [mapView2 convertCoordinate:view.annotation.coordinate toPointToView:mapView2];
float boxDY=annotationPoint.y;
float boxDX=annotationPoint.x;
CGRect box = CGRectMake(boxDX,boxDY,5,5);
UILabel *displayLabel = [[UILabel alloc] initWithFrame:box];
[popoverControllerDetail presentPopoverFromRect:displayLabel.frame inView:mapView2 permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[displayLabel release];
Run Code Online (Sandbox Code Playgroud)
关于这一点的不好的部分是我伪装成注释的视图.我只需获取注释视图(MKMapKit样式坐标)的annotation.coordinate并将坐标转换为屏幕坐标.然后我创建了一个uilabel(在屏幕上获得一个支持框架的构造)放置在Annotation View的位置.然后我告诉popovercontroller出现在那个框架位置.
这是踢球者.我没有将uilabel添加到mapView2.一旦popovercontroller自己绘制,我就会释放它.
哈克,但干净.
| 归档时间: |
|
| 查看次数: |
8064 次 |
| 最近记录: |