【发布时间】:2015-01-04 14:10:14
【问题描述】:
我有这个比较简单的辅助方法:
- (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
我不知道为什么以及如何解决这个问题。有什么想法吗?
【问题讨论】:
-
令人惊讶的是它没有识别错误的行!
-
但很可能是这一行:
CGFloat newHeight = [self imageHeightForRowAtIndexPath:indexPath.row];(Chuck.row)
标签: objective-c compiler-errors implicit-conversion