0
我有這種相對簡單的helper方法:隱式轉換錯誤NSIndexPath
- (float)imageHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
float imageWidth = [[self.widthArray objectAtIndex:indexPath.row] floatValue];
float ratio = screenWidth/imageWidth;
float imageHeight = ratio * [[self.heightArray objectAtIndex:indexPath.row] floatValue];
return imageHeight;
}
的另一種方法,但這種方法調用的時候,其工作完全正常:
- (UIImage *)imageWithImage:(UIImage *)image forRowAtIndexPath:(NSIndexPath *)indexPath
{
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat newWidth = screenRect.size.width;
CGFloat newHeight = [self imageHeightForRowAtIndexPath:indexPath.row];
UIGraphicsBeginImageContext(CGSizeMake(newWidth, newHeight));
[image drawInRect:CGRectMake(0, 0, newWidth, newHeight)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
編譯器說: Implicit conversion from 'NSInteger' to 'NSIndexPath' is disallowed
我不知道爲什麼以及如何解決這個問題。任何想法?
驚人的,它不識別錯誤的行! – 2015-01-04 14:11:55
但很可能是這一行:'CGFloat newHeight = [self imageHeightForRowAtIndexPath:indexPath.row];'(Chuck'.row') – 2015-01-04 14:12:52