2010-09-24 63 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。也許你可以發佈該類別方法的接口?

相關問題