错误:“ - [NSCFString sizeWithTextStyle:]:unrecognized selector”在IPhone SDK [英] Error: "-[NSCFString sizeWithTextStyle:]: unrecognized selector" in IPhone SDK

查看:266
本文介绍了错误:“ - [NSCFString sizeWithTextStyle:]:unrecognized selector”在IPhone SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在运行应用时遇到以下错误。



' - [NSCFString sizeWithTextStyle:]:无法识别的选择器 b
$ b

我在整个项目中没有使用sizeWithTextStyle。



那么什么可能会出错呢?



我在 return pos; 下面的语句中遇到错误



strong>

 (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 
{
UIView * pos = [[UIView alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,35.0)];
return pos;
}

控制台发生错误



由于未捕获异常而终止应用程序'NSInvalidArgumentException',reason:' - [NSCFString sizeWithTextStyle:]:无法识别的选择器发送到实例0x7044b50'



由于在整个崩溃日志的缩进问题在这里,我把崩溃日志的截图



解决方案

我认为,问题是在别的地方,不在这行代码。对象不能保留自身。发布代码,您正在使用 sizeWithTextStyle 方法



您的链接设置上是否有-all_load标志?



这个问题出现了很多。 您需要向应用程序链接标记中添加-all_load和-ObjC。



* EDIT:* p>

崩溃似乎发生在行上:

  CGSize textSize = text sizeWithTextStyle:textStyle]; 
in class:CPTextLayer方法:sizeToFit

从类CPTextLayer方法中调用initWithText:
- (id)initWithText:(NSString *)newText style:(CPTextStyle *) newStyle
....
[self sizeToFit];


**尝试使用iOS 4而不是3.1.3设置**


I get the following error while running my app.

'-[NSCFString sizeWithTextStyle:]: unrecognized selector

I have not used sizeWithTextStyle in my entire project.

So what could be wrong?

I get error on return pos; statement below

Code:

(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
     UIView *pos = [[UIView alloc] initWithFrame:CGRectMake(0.0,0.0,320.0,35.0)];
     return pos;
}

Error in Console:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString sizeWithTextStyle:]: unrecognized selector sent to instance 0x7044b50'

Because of indentation problem while putting whole crash log here, I am putting the screenshot of the crash log

解决方案

I think, the problem is somewhere else, not in this line of code. The object is not able to retain itself. Post the code, where you are using the sizeWithTextStyle method

Have you the -all_load flag on your link settings?

This issue comes up a lot. You need to add -all_load and -ObjC to your applications link flags.

*EDIT : *

Crash appears to occur on line:

 CGSize textSize = [self.text sizeWithTextStyle:textStyle];
 in class: CPTextLayer method: sizeToFit

 which is called from within class CPTextLayer method initWithText:
-(id)initWithText:(NSString *)newText style:(CPTextStyle *)newStyle
....
[self sizeToFit];


**try to set with iOS 4 and not with 3.1.3 **

这篇关于错误:“ - [NSCFString sizeWithTextStyle:]:unrecognized selector”在IPhone SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆