2012-05-24 4 views
0
NSString *HTML = [NSString stringWithFormat:@"<html> \n" 
         "<head> \n" 
         "<meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; maximum-scale=1.0;\">" 
         "<div id='main' style type=\"text/css\"> \n" 
         "body {font-family: \"%@\"; font-size: %@; color:rgb(30,30,30); line-height: %ipx;}\n" 
         "</div> \n" 
         "</head> \n" 
         "<body>%@</body> \n" 
         "</html>", @"helvetica", [NSNumber numberWithInt:[UIFont mainTextFont].pointSize], kWebViewLineSpacing, text]; 

콘텐츠에 div id main을 적용하려고하는데 작동 방법을 파악할 수 없습니다. 나는 문제의 라인이 생각 : "<div id='main' style type=\"text/css\"> \n"하지만 난 작동하도록 조정 얼마나 확실하지 않다기본 HTML - div ID 적용

답변

2
당신은 머리 부분에 사업부를두고있어

, 문제가 해결되지 것

NSString *HTML = [NSString stringWithFormat:@"<html> \n" 
        "<head> \n" 
        "<meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; maximum-scale=1.0;\">" 
        "<style type=\"text/css\"> \n" 
        "body {font-family: \"%@\"; font-size: %@; color:rgb(30,30,30); line-height: %ipx; -webkit-transform: translate3d(0,0,0); word-wrap: break-word; -webkit-hyphens: auto; hyphens: auto; text-overflow: ellipsis; -webkit-text-size-adjust: none; overflow: hidden;}\n" 
        "</style> \n" 
        "</head> \n" 
        "<body><div id=\"main\">My main div</div></body> \n" 
        "</html>", @"helvetica", [NSNumber numberWithInt:[UIFont mainTextFont].pointSize], kWebViewLineSpacing, text]; 
0
..

DIV 머리의 자식으로 유효하지 않습니다 그것은 그 라인은 아무 의미없는 몸

1

의 자식이어야합니다 나는 당신이 의미 믿습니다

"<div id='main'><style type=\"text/css\"> \n" 
2

당신은 함께 당신을 일을 혼합하고 더 많은 것을 원해. ke

[NSString stringWithFormat:@"<html> \n" 
         "<head> \n" 
         "<meta name=\"viewport\" content=\"width=device-width; initial-scale=1.0; maximum-scale=1.0;\">" 
         "<style type=\"text/css\"> \n" 
         "body {font-family: \"%@\"; font-size: %@; color:rgb(30,30,30); line-height: %ipx;}\n" 
         "</style> \n" 
         "</head> \n" 
         "<body><div id='main'>%@</div></body> \n" 
         "</html>", @"helvetica", [NSNumber numberWithInt:[UIFont mainTextFont].pointSize], kWebViewLineSpacing, text];