2010-09-24 39 views
0

下面这行是抛出错误,它是怎么回事?错误:请求将'objc_object *'转换为非标量类型'CGSize'。请帮忙?

CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width];

我的代码:

MSHook(void, drawRectLabel, SBIconLabel *self, SEL sel, CGRect rect) { 

CGRect bounds = [self bounds]; 

NSString *label(MSHookIvar<NSString *>(self, "_label")); 

NSString *style = [NSString stringWithFormat:@"color: white; "]; 

CGSize size = [label sizeWithStyle:style forWidth:bounds.size.width]; 
[label drawAtPoint:CGPointMake((bounds.size.width - size.width)/2, 0) withStyle:style]; 

}

+0

sizeWithStyle:forWidth的返回类型是什么? – TomH 2010-09-24 12:50:15

+0

'-sizeWithStyle:forWidth:'必须位于自定义类别中,因为它没有记录为iOS SDK的一部分。不知道这个方法做了什么,我们无法回答你的问题。 – 2010-09-24 17:08:10

回答

1

我不熟悉-sizeWithStyle:forWidth :,但我的猜测是它返回一个对象,而不是CGSize。也许你可以发布该类别方法的接口?

相关问题