webview_content

${webview_title}

       

${webview_content}


#import

@interface WebContentManager : NSObject

+ (instancetype)sharedManager;

+ (NSString *)faceTimuPatternedWithContentAndNoHead:(NSString *)timu;

@end

path = [[NSBundle mainBundle] pathForResource:@"facetimu" ofType:@"html"];

        shared_manager.facetimu_htmlStr = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];

        if(error) {

            DebugLog(@"facetimu_htmlStr fail: %@", error.description);

        }


#import "WebContentManager.h"

@interface WebContentManager ()

@property (strong, nonatomic) NSString *facetimu_htmlStr;

@end

@implementation WebContentManager

+ (instancetype)sharedManager {

    staticWebContentManager*shared_manager =nil;

    static dispatch_once_t pred;

    dispatch_once(&pred, ^{

        shared_manager = [[selfalloc]init];


        NSString *path = [[NSBundle mainBundle] pathForResource:@"bubble" ofType:@"html"];

        NSError*error =nil;


        //面试题目

        path = [[NSBundle mainBundle] pathForResource:@"facetimu" ofType:@"html"];

        shared_manager.facetimu_htmlStr = [[NSString alloc] initWithContentsOfFile:path encoding:NSUTF8StringEncoding error:&error];

        if(error) {

            DebugLog(@"facetimu_htmlStr fail: %@", error.description);

        }


    });

    returnshared_manager;

}

//面试题目

- (NSString *)faceTimuPatternedWithContent:(NSString *)timu{

    timu = [NSString stringWithFormat:@"%@%@",timu,@"
"];

    NSString*patternedStr =self.facetimu_htmlStr;

    patternedStr = [patternedStrstringByReplacingOccurrencesOfString:@"${webview_content}" withString:timu];

    returnpatternedStr;

}

//面试题目2 跟上面的区别是把\n转成换行了

- (NSString *)faceTimu2PatternedWithContent:(NSString *)timu{

    timu = [timustringByReplacingOccurrencesOfString:@"\r" withString:@"\n"];

    timu = [selfdeleteMoreN:timu];

//    timu = [timu stringByReplacingOccurrencesOfString:@"\n" withString:@""];

//    timu = [timu stringByReplacingOccurrencesOfString:@"\\s{1}" withString:@"\n"];

//    timu = [timu stringByReplacingOccurrencesOfString:@"\n\n" withString:@"\n"];

    timu = [timustringByReplacingOccurrencesOfString:@"\n" withString:@"
"];


    timu = [NSString stringWithFormat:@"%@%@",timu,@"
"];

    NSString*patternedStr =self.facetimu1_htmlStr;

    patternedStr = [patternedStrstringByReplacingOccurrencesOfString:@"${webview_content}" withString:timu];

    returnpatternedStr;

}

- (NSString*)deleteMoreN:(NSString*)timu{

    NSString*newTimu =@"";

    NSArray *arr = [timu componentsSeparatedByString:@"\n"];

    BOOLisNew =NO;

    for(NSString*iteminarr) {

        if([itemisEqualToString:@""]) {

            if(!isNew) {

                newTimu = [newTimustringByAppendingString:@"\n"];

                isNew =YES;

            }

            else{


            }

        }

        else{

            isNew =NO;

            newTimu = [newTimustringByAppendingString:item];

        }

    }


    returnnewTimu;

}

+ (NSString *)faceTimuPatternedWithContentAndNoHead:(NSString *)timu{

    return [[self sharedManager] faceTimuPatternedWithContent:timu];

}

@end




[_timuWebView loadHTMLString:[WebContentManager faceTimuPatternedWithContentAndNoHead:detailModel.ask] baseURL:nil];

            _timuWebView.UIDelegate=self;

            _timuWebView.navigationDelegate=self;

你可能感兴趣的:(webview_content)