Iphone 在另一个字符串的中间插入一个特定但未知的点-目标c

Iphone 在另一个字符串的中间插入一个特定但未知的点-目标c,iphone,objective-c,ios,nsstring,Iphone,Objective C,Ios,Nsstring,这件事我已经纠结了好几天了 我有一个字符串块,它是html,我将它作为html文本加载到web视图中。我想做的是在字符串的中间插入一个图像,但要在段落的开头或结尾插入,这样我就保留了字符串的整体格式 例如,如果我有 <p> some text <p> would like to insert image here <p> more text 一些文本 想在这里插入图像吗 更多文本 是否有任何方法可以做到这一点您可以使用下面的字符串加载webview

这件事我已经纠结了好几天了

我有一个字符串块,它是html,我将它作为html文本加载到web视图中。我想做的是在字符串的中间插入一个图像,但要在段落的开头或结尾插入,这样我就保留了字符串的整体格式

例如,如果我有

<p>
some text 
<p>
would like to insert image here
<p>
more text

一些文本

想在这里插入图像吗

更多文本

是否有任何方法可以做到这一点

您可以使用下面的字符串加载webview

NSString* mTheBackgroundPath = [[NSBundle mainBundle] pathForResource:@"logo_s28" ofType:@"png"];
    mTheBackgroundPath = [  mTheBackgroundPath stringByReplacingOccurrencesOfString:@"/" withString:@"//"];
    mTheBackgroundPath = [ mTheBackgroundPath stringByReplacingOccurrencesOfString:@" " withString:@"%20"];
    mTheBackgroundPath = [@"file://" stringByAppendingString:mTheBackgroundPath];
    NSString *htmlString = [NSString stringWithFormat:@"<p>
                            some text 
                            <p>
                            %@
                            <p>
                            more text",mTheBackgroundPath];
NSString*mTheBackgroundPath=[[NSBundle mainBundle]路径用于资源:@“logo_s28”,类型:@“png”];
mTheBackgroundPath=[mTheBackgroundPath stringByReplacingOccurrencesOfString:@/“with string:@/”];
mTheBackgroundPath=[mTheBackgroundPath stringByReplacingOccurrencesOfString:@“with string:@”%20“];
mTheBackgroundPath=[@“file://”stringByAppendingString:mTheBackgroundPath];
NSString*htmlString=[NSString stringWithFormat:@“
一些文本

%@

“更多文本”,mTheBackgroundPath];