I have a mobile application that utilizes a WebView to showcase text and images. For iOS 8, I need to set the margin and padding values to 0px in order to properly display the HTML page. However, for iOS 7 compatibility, the margin and padding must be adjusted to 4px.
Is there a way to automatically adjust the layout based on the iOS version?
The goal is to dynamically set the padding and margin to 0px for iOS 8 and 4px for iOS 7. Below is my current stylesheet stored in an NSString:
NSString *stylesheet=@"<html><head><style>body { margin: 0; padding: 0; }h1{font-weight:normal;font-family: HelveticaNeue-Thin; padding: 7px; margin-bottom: 3px;}p{font-family: HelveticaNeue-Light; padding-top:0px; padding-left: 7px;paddin-right: 7px; margin-top:10px;}imgcenter {display: block; margin: 0 auto;}b{font-weight:normal;font-family: HelveticaNeue-Medium;}</style></head><body>";
NSString *footer=@"</body></html>";
[super viewDidLoad];
NSString *fullURL = [NSString stringWithFormat:@"%@%@%@",stylesheet, self.SelectedProduct.content, footer];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSURL *baseURL = [NSURL fileURLWithPath:path];
[_webview loadHTMLString:fullURL baseURL:baseURL];