此代码记录UIImage的宽度,但加载的纹理宽度为0:
NSDictionary * options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES],
GLKTextureLoaderOriginBottomLeft,
nil];
NSError * error;
UIImage * iu = [UIImage imageNamed:fileName];
CGImageRef cg=iu.CGImage;
NSLog(@"image size width: %f", iu.size.width);
self.textureInfo= [GLKTextureLoader textureWithCGImage:cg options:options error:&error];
if (self.textureInfo == nil) {
NSLog(@"Error loading file: %@", [error localizedDescription]);
return nil;
}
NSLog(@"texture width: %f", self.textureInfo.width);
如果最后一个日志行显示0
我做错了什么?没有记录错误。
答案 0 :(得分:0)
问题在于日志记录,而不是纹理加载。这是一个int
:
NSLog(@"texture width: %i", self.textureInfo.width);