Webview clipped to ios7

! [enter image description here] [1]! [enter image description here] [2] Hy, I developed a reader that shows the contents of the html file on the website after adding horizontal paging to it using .css, Everything worked fine, but on ios7 I noticed that the webview was cropped on the left edge I tried the following:

readingWebView.frame = CGRectMake(0, 0, 768, 920);   
[readingWebView loadHTMLString:loadString baseURL:nil];
readingWebView.autoresizingMask = UIViewAutoresizingFlexibleHeight |        UIViewAutoresizingFlexibleWidth;
readingWebView.clipsToBounds = false;
self.edgesForExtendedLayout=UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars=NO;
self.automaticallyAdjustsScrollViewInsets = NO;

this css file that I have:

html {
height:820px;
//margin:0px;
font-size:24px;
width:628px;
}

body {
margin:0px;
    padding:0px;
    width:628px;

}

#viewer {
    width:628px;
    height:820px;

}

#book {
width:628px;
height:820px;

margin-left:50px;
margin-right:50px;
//margin-top:100px;

-webkit-column-count:auto;
-webkit-column-width:668px;
-webkit-column-gap:140px;
text-align:justify;

 }

.h {
margin-top:8px;
 }
+4
source share
4 answers

, CSS. -, webkit , ,   . , .

html ,   , ? , javascript,   !


edit: , javascript:

var bodyText = "هذا هو بلدي النص الأساسي.";
var newBodyText = bodyText.replace(" ","  ");

, - RTL, , , string.replace RTL

var bodyText = "هذا هو بلدي النص الأساسي.";
var newBodyText = bodyText.replace(" ","  ");

edit edit:

RegEx ( HTML < * > script, Objective-C, , ( RegEx, , , RegEx , , , !)).

NSString *string = originalHTMLString;

NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(?i)(<script(?:[^>\"']|\"[^\"]*\"]|'[^']*')*>)\s+</script\\s*>|<style(?:[^>\"']|\"[^\"]*\"]|'[^']*')*>)\s+</style\\s*>|<textarea(?:[^>\"']|\"[^\"]*\"]|'[^']*')*>)\s+</textarea\\s*>|</?[a-z](?:[^>\"']|\"[^\"]*\"]|'[^']*')*>|\\S+)|\\s+" options:NSRegularExpressionCaseInsensitive error:&error];
NSString *modifiedString = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:@"&nbsp; "];

finalHTMLString = modifiedString;

... , , RTL-, , nbsp AFTER ( ) :

NSString *string = originalHTMLString;

NSError *error = nil;
NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:@"(?i)(<script(?:[^>\"']|\"[^\"]*\"]|'[^']*')*>)\s+</script\\s*>|<style(?:[^>\"']|\"[^\"]*\"]|'[^']*')*>)\s+</style\\s*>|<textarea(?:[^>\"']|\"[^\"]*\"]|'[^']*')*>)\s+</textarea\\s*>|</?[a-z](?:[^>\"']|\"[^\"]*\"]|'[^']*')*>|\\S+)|\\s+" options:NSRegularExpressionCaseInsensitive error:&error];
NSString *modifiedString = [regex stringByReplacingMatchesInString:string options:0 range:NSMakeRange(0, [string length]) withTemplate:@" &nbsp;"];

finalHTMLString = modifiedString;
+2

UIWebView , , viewport, .

Google, Apple dev

+1

, , , , Apple webViewDelegate, ?... :

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog(@"Adjusting SubView Clippings");//<-- Wait until this logs otherwise this code hasn't been called yet, even if webView looks like it been displayed!
    for (UIView *view in [webView subViews]) {
        view.clipsToBounds = NO;
    }
}

, , :
view.superview.clipsToBounds = NO;

, , , UIWebView CSS margin, ? , UIWebView, objective-c. ? (clipToBounds , -)

+1
source

This is a known bug in WebKit. This happens in all RTL languages. For our application, this happens when the meta tag view window is not enough to capture the entire RTL element.

If you represent only formatted text and possibly images, I recommend going to UITextView.

+1
source

Source: https://habr.com/ru/post/1526935/


All Articles