我是XCode的初学者,我正试图找到一种方法让用户在他们放在地图上的图钉的一个电话亭内输入信息。
因此,如果用户放下一个引脚并点击该引脚,我希望他们能够输入该位置的标题和副标题。
到目前为止,我已经使用MKMapView创建了一个地图,并且我已经实现了UILongPressGestureRecognizer和一个void方法,可以在创建引脚时触发。
我不确定下一步该做什么?谢谢您的帮助。
Edit1:我没有发布图片所需的声誉,所以这里是我想要完成的链接:http://imgur.com/gixFxpI
如果可以在不使用公开按钮的情况下输入标题和副标题,那就会膨胀。稍后我将开发披露按钮。
Edit2:我有三个新问题:1。为什么我的标注按钮出现在我的标注中? 2.什么是reuseidentifier?这是我到目前为止所拥有的。
我已将导航控制器嵌入到我的初始视图控制器中,其中包含MKMapView。我创建了第二个视图控制器,我将MKMapView连接到第二个视图控制器,并将我的第二个视图控制器的标识符设置为'heylisten'(旧的Zelda)。
我的第三个问题是在prepareForSegue方法中,点之后需要了解哪些信息? destinationViewController。???? = sender.annotation;
// This is your callout box
- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation
{
MKAnnotationView *annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"overhere"];
annotationView.canShowCallout = YES;
UIButton *rightDisclosureButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.rightCalloutAccessoryView = rightDisclosureButton;
return annotationView;
}
// This is a segue when you tap the right disclosure button
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control
{
[self performSegueWithIdentifier:@"heylisten" sender:view];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(MKAnnotationView *)sender
{
if ([segue.identifier isEqualToString:@"heylisten"])
{
ViewController *destinationViewController = segue.destinationViewController;
// grab the annotation from the sender
destinationViewController = sender.annotation;
}
}
答案 0 :(得分:0)
如果你的目标是iOS 8,请使用UIAlertController:
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertController_class/
如果您要定位iOS 7或更早版本,请使用UIAlertView:
这两种类型都有添加输入文本字段的机制,并指定要使用用户键入的文本执行的回调。