1

サーバーから渡されたデータに基づいてすべての注釈を作成するためのコードは次のとおりですが、生成される「取引」またはピンがない場合があるため、作成する取引が生成されない場合はどうすればよいですか? UIAlertView? 私がこれまでに持っているコードは次のとおりです。

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation {

    if([annotation isKindOfClass:[MKUserLocation class]]) {
        return nil;
    }

    static NSString *identifier = @"MyLocation";
    if ([annotation isKindOfClass:[Annotation class]]) {

        MKPinAnnotationView *view = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:identifier];
        if (view == nil) {
            view = [[MKPinAnnotationView alloc]
                    initWithAnnotation:annotation
                    reuseIdentifier:identifier];

            UIAlertView *alert=[[UIAlertView alloc]initWithTitle:nil message:@"No Deals! Please Try Your Request Again!" delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];

            [alert show];
        } else {

            view.annotation = annotation;
        }

       if([[(Annotation*)annotation phoneNumber] isEqualToString:@"0"]){


            view.enabled = YES;
            view.canShowCallout = YES;
            view.pinColor = MKPinAnnotationColorPurple;
            // Create a UIButton object to add on the
            self.leftBtn = [UIButton buttonWithType:UIButtonTypeInfoDark];
            [self.leftBtn setTitle:annotation.title forState:UIControlStateNormal];
            view.rightCalloutAccessoryView = nil;
            [view setLeftCalloutAccessoryView:self.leftBtn];

        }else{

            view.enabled = YES;
            view.canShowCallout = YES;

            // Create a UIButton object to add on the
            self.rightBtn = [UIButton buttonWithType:UIButtonTypeInfoDark];
            [self.rightBtn setTitle:annotation.title forState:UIControlStateNormal];

            [view setRightCalloutAccessoryView:self.rightBtn];

        }

        if ([[(Annotation*)annotation phoneNumber] isEqualToString:@"1"]){

            view.enabled = YES;
            view.canShowCallout = YES;
            view.pinColor = MKPinAnnotationColorGreen;
            // Create a UIButton object to add on the
            self.leftBtn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
            [self.leftBtn setTitle:annotation.title forState:UIControlStateNormal];
            view.rightCalloutAccessoryView = nil;
            [view setLeftCalloutAccessoryView:self.leftBtn];

        }


        return view;
    }

    return nil;
}

これは、http 要求メソッドで作成する必要があるものですか? 何か案は?

4

0 に答える 0