无法在UIWebview中加载HTML字符串

问题描述 投票:0回答:2

我想在uiwebview中显示一个HTML字符串,它给出了以下错误:

 **-[__NSArrayI dataUsingEncoding:]: unrecognized selector sent to instance 0x75caf40
2013-09-17 10:26:48.774 iphoneApp[9395:2903] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI dataUsingEncoding:]: unrecognized selector sent to instance 0x75caf40'
*** First throw call stack:
(0x1cca012 0x1107e7e 0x1d554bd 0x1cb9bbc 0x1cb994e 0x26fc8ea 0x26fc97a 0x2027fa 0x35a2548 0x1c4df3f 0x1c4da39 0x1c70734 0x1c6ff44 0x1c6fe1b 0x35a1c50 0x9628f5b7 0x96279d4e)
libc++abi.dylib: terminate called throwing an exception*
*emphasized text**

这是代码:

NSString *json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSString *desc = [json valueForKey:@"description"];
NSLog(@"%@",desc);
[self.jobdescription loadHTMLString:desc baseURL:nil];

如果我从NSLog复制输出字符串并将其放在loadHTMLString中它很好但如果我把“desc”相同,我将得到错误。我不知道会出现什么问题。谢谢

iphone ios ios5 ios6 uiwebview
2个回答
0
投票

请尝试以下语句。

[self.jobdescription loadHTMLString:[NSString stringWithFormat:@"%@",desc] baseURL:nil];

请检查“self.jobdescription”是否是UIWebView对象。


0
投票

好像desc不是字符串而是数组。添加NSLog(@"%@", NSStringFromClass([desc class]));以确保。

© www.soinside.com 2019 - 2024. All rights reserved.