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