开发者

warning: incompatible Objective-C types

开发者 https://www.devze.com 2023-01-07 03:41 出处:网络
Warning: incompatible Objective-C types \'struct NSArray *\', expected \'struct UIFont *\' when passing argument 1 of \'setFont:\' from distinct Objective-C type

Warning: incompatible Objective-C types 'struct NSArray *', expected 'struct UIFont *' when passing argument 1 of 'setFont:' from distinct Objective-C type

Code Like:

lblTemp.font = [UIFont fontNamesForFamilyName:@"Arial"]; // Warning comes here    
lblTemp.font = [UIFont fontWithName:@"Arial-BoldMT开发者_运维问答" size:13];    
[cell.contentView addSubview:lblTemp];    
[lblTemp release];

Please give some suggestion to solve to it.


-fontNamesForFamilyName: returns an array of font names, not a UIFont. You'll want to pass one of the strings in this array to +[UIFont fontWithName:size:] to get a UIFont object back (as you do in the next line).


[UIFont fontNamesForFamilyName:@"Arial"];
does not return the Arial font, it returns the array of font names for the Arial font family. Check the manual here

0

精彩评论

暂无评论...
验证码 换一张
取 消