我在iOS应用程序中使用了带有PaginationMode UIWebPaginationModeLeftToRight的UIWebView,该应用程序运行正常。但最近iOS的更新,即iOS 10.3.2停止了 background-color 属性,尽管 color 属性正在运行。我试图通过多种方式解决问题,例如将UIWebView的不透明属性设置为NO,以及将不同的方式分配给body标签。由于我无法解决问题,我来这里询问这个问题。我相信有人会帮我解决这个问题。我要测试的示例代码如下:
//
// ViewController.m
// UIWebViewBackground
#import "ViewController.h"
@interface ViewController () <UIWebViewDelegate>
{
UIWebView *webview;
}
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"UIWebView Demo";
if(webview == nil)
{
webview = [[UIWebView alloc] initWithFrame: self.view.bounds];
webview.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
[self.view addSubview:webview];
[self.view layoutSubviews];
CGFloat width = [[UIScreen mainScreen] bounds].size.width;
[webview setPageLength:width];
webview.delegate = self;
webview.scrollView.pagingEnabled = YES;
[webview setPaginationMode: UIWebPaginationModeLeftToRight];
[webview setPaginationBreakingMode:UIWebPaginationBreakingModeColumn];
// load the skeleton HTML into webview
NSString *myHTML = @"<htm><body style=\"background-color:green; color:red;\"><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/><h1>UI WebView</h1><br/></body></html>";
[webview loadHTMLString:myHTML baseURL:nil];
}
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
当我评论以下两行代码时,背景颜色和颜色属性都正常工作但是当我取消注释背景颜色时根本不起作用。< / p>
//[webview setPaginationMode: UIWebPaginationModeLeftToRight];
//[webview setPaginationBreakingMode:UIWebPaginationBreakingModeColumn];