Iphone 在iOS5中,我在多媒体资料中切换图片的方法不好

Iphone 在iOS5中,我在多媒体资料中切换图片的方法不好,iphone,objective-c,ios,ipad,ios5,Iphone,Objective C,Ios,Ipad,Ios5,我有一些在画廊里看图片的课程。在启用ARC后的这些类中,我得到一条消息,即ARC禁止隐式转换,并且我无法运行应用程序 这些方法是: - (void) curlToPrevious { if (currentImageIndex == 0) return; if ([self.image2 superview] == NO) { self.image2.image = (UIImage*) [imageViews objectAtIndex:(cu

我有一些在画廊里看图片的课程。在启用ARC后的这些类中,我得到一条消息,即ARC禁止隐式转换,并且我无法运行应用程序

这些方法是:

- (void) curlToPrevious
{
    if (currentImageIndex == 0) return;



         if ([self.image2 superview] == NO) {

        self.image2.image = (UIImage*) [imageViews objectAtIndex:(currentImageIndex-1)];
    } else {
        self.image1.image = (UIImage*) [imageViews objectAtIndex:(currentImageIndex-1)];
    }

    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:kTransitionDuration];

    currentImageIndex--;

    [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.containerView cache:YES];

    if ([self.image2 superview] == NO) {
        [self.image1 removeFromSuperview];
        [self.containerView addSubview:self.image2];
    } else {
        [self.image2 removeFromSuperview];
        [self.containerView addSubview:self.image1];
    }

    [UIView commitAnimations];
    [self updateCurrentImageCounter];
}

- (void) curlToNext
{
    if (currentImageIndex == ([self imageCount]-1)) return;

    if ([self.image2 superview] == NO) {
        self.image2.image = (UIImage*) [imageViews objectAtIndex:(currentImageIndex+1)];
    } else {
        self.image1.image = (UIImage*) [imageViews objectAtIndex:(currentImageIndex+1)];
    }
    currentImageIndex++;


    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:kTransitionDuration];

    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.containerView cache:YES];

    if ([self.image2 superview] == NO) {
        [self.image1 removeFromSuperview];
        [self.containerView addSubview:self.image2];
    } else {
        [self.image2 removeFromSuperview];
        [self.containerView addSubview:self.image1];
    }

    [UIView commitAnimations];
    [self updateCurrentImageCounter];
}
我有

if ([self.image2 superview] == NO) {
在这行代码的4个地方有问题

我得到的文本是:

ARC不允许将“int”隐式转换为“UIView”


我怎样才能避免这个???谢谢。

如果([self.image2 superview]==nil)您正在将UIView*整数进行比较,您可以替换此
上的代码,当然会收到警告。是否要检查superview是否为零?那么就这么做吧:

if([self.image2 superview]==nil){…}