Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.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
Iphone 仅显示一个注释_Iphone_Objective C_Arrays_Sdk - Fatal编程技术网

Iphone 仅显示一个注释

Iphone 仅显示一个注释,iphone,objective-c,arrays,sdk,Iphone,Objective C,Arrays,Sdk,Hi my array由三个对象填充,地图上仅显示一个注释。有什么想法吗?如果我记录某些元素,它将被填充。只是无法显示3个注释 NSMutableArray *currentBranch = [xmlParser branch]; int counter=[currentBranch count]; NSMutableArray *new = [[NSMutableArray alloc] init]; CLLocationCoordinate2D coordinates; Mapdets

Hi my array由三个对象填充,地图上仅显示一个注释。有什么想法吗?如果我记录某些元素,它将被填充。只是无法显示3个注释

NSMutableArray *currentBranch = [xmlParser branch];
int counter=[currentBranch count];

NSMutableArray *new = [[NSMutableArray alloc] init];

CLLocationCoordinate2D coordinates;
Mapdets * myAnn;
myAnn = [[Mapdets alloc] init];

[mapview setMapType:MKMapTypeStandard];
[mapview setZoomEnabled:YES];
[mapview setScrollEnabled:YES];

MKCoordinateRegion region = {{0.0, 0.0}, {0.0,0.0 }};
region.center.latitude = -33.86434888;
region.center.longitude = 151.2090236;
region.span.longitudeDelta = 55.80f;
region.span.latitudeDelta = 55.80f;
[mapview setRegion:region animated:YES];


for(int i=0;i<counter;i++)

{
 Mapdets *currentBranch = [[xmlParser branch] objectAtIndex:i];




NSString *title = currentBranch.title;
NSString *subtitle = currentBranch.subtitle;
NSString *lat = currentBranch.lat;  
NSString *lng = currentBranch.lng;     


coordinates.latitude = [lat doubleValue];  
coordinates.longitude = [lng doubleValue];

    myAnn.coordinate = coordinates;
    myAnn.title = title;
    myAnn.subtitle = subtitle;

 NSLog(@"%@",  title);

 [new addObject:myAnn];
}

[mapview addAnnotations:new];
NSMutableArray*currentBranch=[xmlParser-branch];
int计数器=[currentBranch count];
NSMutableArray*new=[[NSMutableArray alloc]init];
CLLocationCoordinate2D坐标;
Mapdets*myAnn;
myAnn=[[Mapdets alloc]init];
[mapview setMapType:MKMapTypeStandard];
[mapview SetZoomeEnabled:是];
[地图视图设置可克隆:是];
MKCoordinateRegion={0.0,0.0},{0.0,0.0};
region.center.lation=-33.86434888;
region.center.longitude=151.2090236;
region.span.longitudeDelta=55.80f;
region.span.latitudeDelta=55.80f;
[地图视图设置区域:区域动画:是];

for(int i=0;i只需在for循环中初始化myAnn即可

for(int i=0;i<counter;i++)
{
    Mapdets * myAnn;
    myAnn = [[Mapdets alloc] init];
    Mapdets *currentBranch = [[xmlParser branch] objectAtIndex:i];
    NSString *title = currentBranch.title;
    NSString *subtitle = currentBranch.subtitle;
    NSString *lat = currentBranch.lat;  
    NSString *lng = currentBranch.lng;     

    coordinates.latitude = [lat doubleValue];  
    coordinates.longitude = [lng doubleValue];

    myAnn.coordinate = coordinates;
    myAnn.title = title;
    myAnn.subtitle = subtitle;

    NSLog(@"%@",  title);
   [new addObject:myAnn];
}

for(int i=0;i[mapview addAnnotations:new];将此保留在循环中地图缩放级别是什么…查看坐标是否在区域中…检查循环..其括号在注释之前added@Murali我把它移到for循环中,同样的问题。@Nit,我把它设置为查看整个地图,不,它不在那里。(我一开始就想到了这一点)你检查过for循环后的new计数了吗?。如果它是1,那么尝试在for循环中初始化myAnn。。