Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/118.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios MKMapView show DetailView-如何制作序列_Ios_Mkmapview_Uistoryboard_Uistoryboardsegue - Fatal编程技术网

Ios MKMapView show DetailView-如何制作序列

Ios MKMapView show DetailView-如何制作序列,ios,mkmapview,uistoryboard,uistoryboardsegue,Ios,Mkmapview,Uistoryboard,Uistoryboardsegue,我有一个地图视图,注释来自属性列表。 现在我想在详细视图中看到更多数据。 不幸的是,我不知道如何编程的Segue,以便数据可以显示。 我希望你明白我的意思。我的英语不是很好。。。 我知道方法prepareforSegue中缺少一些。 我正在使用故事板。 提前感谢您的帮助。。。 问候 #导入“MapViewNewController.h” #导入“MapViewAnnotation.h” #导入“SetCardController.h” @接口MapViewNewController() @结束

我有一个地图视图,注释来自属性列表。 现在我想在详细视图中看到更多数据。 不幸的是,我不知道如何编程的Segue,以便数据可以显示。 我希望你明白我的意思。我的英语不是很好。。。 我知道方法prepareforSegue中缺少一些。 我正在使用故事板。 提前感谢您的帮助。。。 问候

#导入“MapViewNewController.h”
#导入“MapViewAnnotation.h”
#导入“SetCardController.h”
@接口MapViewNewController()
@结束
@MapViewNewController的实现
@合成配方字典=_配方字典;
@综合地图视图;
@综合定位经理;
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
}
回归自我;
}
-(无效)viewDidLoad
{
[超级视图下载];
self.mapView.delegate=self;
[self.mapView设置显示位置:是];
新区域协调中心;
newRegion.center.latitude=50.080635;
newRegion.center.longitude=8.518717;
newRegion.span.latitudeDelta=15.5;
newRegion.span.longitudeDelta=15.5;
[mapView setRegion:newRegion动画:是];
NSString*path=[[NSBundle mainBundle]pathForResource:@“plist”类型的“Rezepte”;
NSDictionary*dict=[NSDictionary Dictionary WithContentsOfFile:path];
NSArray*anns=[dict objectForKey:@“myRecipes”];
对于(int i=0;i<[ANN计数];i++){
float realLatitude=[[anns objectAtIndex:i]objectForKey:@“纬度”]floatValue];
float realLongitude=[[anns objectAtIndex:i]objectForKey:@“longitude”]floatValue];
MapViewAnnotation*myAnnotation=[[MapViewAnnotation alloc]init];
CLLOCATION Coordinated2和Coordinate;
坐标纬度=真实纬度;
坐标经度=真实经度;
myAnnotation.coordinate=坐标;
myAnnotation.title=[[anns objectAtIndex:i]objectForKey:@“blogname”];
myAnnotation.subtitle=[[anns objectAtIndex:i]objectForKey:@“blogger”];
[mapView addAnnotation:myAnnotation];
}      
}
-(MKAnnotationView*)地图视图:(MKMapView*)视图注释:(id)注释{
MKPinAnnotationView*pin=nil;
if([annotation isKindOfClass:[MapViewAnnotation class]]){
NSString*pinIdentifier=@“myPin”;
pin=(MKPinAnnotationView*)[view dequeueReusableAnnotationViewWithIdentifier:pinIdentifier];
如果(!pin){
pin=[[MKPinAnnotationView alloc]initWithAnnotation:annotation重用标识符:pinIdentifier];
pin.image=[UIImage ImageName:@“pin2.png”];
pin.canShowCallout=是;
pin.rightCalloutAccessoryView=[UIButton Button类型:UIButtonTypedTailDisplay];
}
}
回位销;
}
//如果按下按钮
-(无效)地图视图:(MKMapView*)地图视图注释视图:(MKAnnotationView*)视图调用访问控制点击:(UIControl*)控制{
[self-PerformsgueWithIdentifier:@“showPinDetails”发件人:self];
}
-(void)prepareForSegue:(UIStoryboardSegue*)segue发送方:(id)发送方{
if([segue.identifier IsequalString:@“showPinDetails”]){
//SetCardController*scc=[segue destinationViewController];
}
}

我相信您没有在Interface Builder中设置Segue的标识符。我试过你的代码,它对我很有用(Xcode 4.4 iOS 5.1 SDK)

当你从
注释视图:视图
中的一个调出中
使用标识符:发送者
执行调出时,发送者可以是
视图。注释
属性,它唯一地标识用户刚刚点击的调出。

以上两个答案有帮助,但是,不要帮助您识别我假设是您p-list的一部分的唯一PIN详细信息

所有视图都继承标记的属性。它可以使用它来保存pin索引(或键),并因此将其传递给目标视图控制器,以唯一标识您保存的数据

当调出视图中的按钮继承自视图时,您可以对其进行标记,并在其在方法DIDSELECTANNOTATION视图中处于活动状态时传递索引。使用的if语句取消选择用户位置pin

-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view
{

if (![(PointAnnotation *)view.annotation isKindOfClass:[MKUserLocation class]])
{
    PointAnnotation *myAnn = (PointAnnotation *)view.annotation;

    detailButton.tag = myAnn.pinIndex;
    NSLog (@"Pinindex = %d", myAnn.pinIndex);
}



}
detailButton.tag现在可以用作segue选择中的参数

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Post data to destination VC

if ([[segue identifier] isEqualToString:@"clubsToDetail"])
{


    ClubsMasterData *current = [[ClubsMasterxmlParser ClubsMasterDatas] objectAtIndex:detailButton.tag];


    ClubsDetailViewController *DVC = [[ClubsDetailViewController alloc] init];
    DVC = [segue destinationViewController];


    DVC.linkURL =  current.linkURL;
    DVC.distance = current.distance;

}
}
这里我索引了一个数组而不是Plist,但其主体是相同的

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Post data to destination VC

if ([[segue identifier] isEqualToString:@"clubsToDetail"])
{


    ClubsMasterData *current = [[ClubsMasterxmlParser ClubsMasterDatas] objectAtIndex:detailButton.tag];


    ClubsDetailViewController *DVC = [[ClubsDetailViewController alloc] init];
    DVC = [segue destinationViewController];


    DVC.linkURL =  current.linkURL;
    DVC.distance = current.distance;

}
}