J'utilise un UIWebview, mais il y a un fond noir derrière la vue web dans ios8. La même chose fonctionne très bien dans ios7. J'ai également mis opaque à NO.UIWebView Fond transparent dans ios8
5
A
Répondre
-1
Put a instance variable in the in the header file or your class:
// instance variable for interval timer
NSTimer *BackgroundIntervalTimer;
Put these methods in the implementation file:
- (void)startUIWebViewBackgroundFixTimer {
// if > iOS 8 start fixing background color of UIWebPDFView
if (!SYSTEM_VERSION_LESS_THAN(@"8.0")) {
// hide pdfWebView until background fixed
self.pdfWebView.alpha = 0.0;
// start interval timer
BackgroundIntervalTimer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(fixBackground) userInfo:nil repeats:YES];
}
}
- (void)stopUIWebViewBackgroundFixTimer {
[BackgroundIntervalTimer invalidate];
BackgroundIntervalTimer = nil;
}
- (void)fixBackground {
// stop timer interval
[self stopUIWebViewBackgroundFixTimer];
// Assuming self.webView is our UIWebView
// We go though all sub views of the UIWebView and set their backgroundColor to white
UIView *v = self.pdfWebView;
while (v) {
//v.backgroundColor = [UIColor whiteColor];
v = [v.subviews firstObject];
if ([NSStringFromClass([v class]) isEqualToString:@"UIWebPDFView"]) {
[v setBackgroundColor:[UIColor whiteColor]];
// background set to white so fade view in and exit
[UIView animateWithDuration:0.25 delay:0.0 options:UIViewAnimationOptionCurveEaseOut
animations:^{
self.pdfWebView.alpha = 1.0;
}
completion:nil];
return;
}
}
// UIWebPDFView doesnt exist yet so exit and try later
[self startUIWebViewBackgroundFixTimer];
}
Now put this line right after the line where you load the pdf:
// if iOS 8 check if pdfWebView got subview of class UIWebPDFView
[self startUIWebViewBackgroundFixTimer];
0
Essayez d'ajouter UIWebview en tant que sous-vue par programmation.
WebView = [[UIWebView alloc]initWithFrame:CGRectMake(264, 10, 745, 576)];
WebView.userInteractionEnabled = YES;
[self setBorderToView: WebView];
WebView.scrollView.bounces = NO;
[WebView setBackgroundColor:[UIColor clearColor]];
[WebView setOpaque:NO];
[WebView loadHTMLString: embedHTML baseURL: nil];
[self.view addSubview: WebView];
Espérons que ce soit utile!
0
J'ai également fait face au même problème, après ne pas avoir obtenu la bonne solution j'ai fait un tour en utilisant le masquage.
CALayer *aLayer = [CALayer layer];
aLayer.backgroundColor = [UIColor blackColor].CGColor;
aLayer.frame = CGRectMake(origin.x, origin.y, widthOfVideo, heightOfVideo);
objWebView.layer.mask = aLayer;
Et cela a fonctionné pour moi. J'espère que cela peut vous être utile.
Questions connexes
- 1. UIWEbView fond transparent: est-il possible?
- 2. Fond transparent dans jpGraph
- 3. Comment faire un UIWebView transparent
- 4. Fond transparent - pas complètement transparent
- 5. UIWebView fond toujours blanc
- 6. ios8 UIWebView svg embaded html pas montrer
- 7. Transparent UIToolBar sur UIWebView
- 8. iOS8 UINavigationController push/pop avec transparent UIView issue
- 9. Fond transparent dans Internet Explorer
- 10. Jquery.corner() fond transparent dans IE
- 11. Fond transparent dans gnuplot multiplot
- 12. Fond transparent FrameBuffer dans OpenGL
- 13. Fond IE et transparent
- 14. css fond transparent
- 15. webview fond transparent
- 16. Div fond transparent
- 17. progrès élément fond transparent
- 18. Fond transparent de VerticalFieldManager
- 19. PHP/GD - fond transparent
- 20. Fond transparent, texte clair?
- 21. texte d'entrée non transparent sur fond transparent
- 22. Les rappels vidéo UIWebView Embed ne fonctionnent pas dans iOS8?
- 23. Fond transparent Java Graphics2D
- 24. SDL RenderTextShaded Fond transparent
- 25. Fond transparent de UITextField
- 26. AChartEngine fond transparent
- 27. AchartEngine fond transparent
- 28. Android EditText Fond transparent
- 29. Fond transparent Iframe
- 30. sIFR 3: Fond transparent?
Même question ici: http://stackoverflow.com/questions/25813551/rendering-pdf-in-uiwebview-ios-8-causes-a-black-border-around-pdf – Boris