'background-attachment:fixed'的解决方法在iOS4中不工作 [英] Workaround for 'background-attachment: fixed' which is not working in iOS4

查看:432
本文介绍了'background-attachment:fixed'的解决方法在iOS4中不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难获取固定背景图片的网页,因此当在UIWebView中滚动页面时,图片不会移动。

我发现的是: background-attachment:fixed 在iOS4中不起作用(使用4.2.1)。
要仔细检查,我已经准备了一个页面,其中包含< head> 部分中的代码片段Mac,但没有这样做在iPhone的Safari ...

I'm struggling to get web page with a fixed background image, so the image does not move when page is scrolled in a UIWebView.
What I've discovered is: background-attachment: fixed does not work in iOS4 (using 4.2.1). To double-check I've prepared a page with code snippet (below) inside <head> section and the page works as expected under Safari and Firefox on Mac, but fails to do so in iPhone's Safari...

你建议什么作为解决方法,以实现预期的结果?我已经使我的UIWebView半透明,并添加了UIImageView,所以我可以看到固定的背景图像通过半透明的页面。不幸的是,当我滚动它的结束/开始边缘时,我可以看到UIWebView边框。

What do you suggest as a workaround for achieving the expected results? I've made my UIWebView translucent and added UIImageView, so I can see "fixed background image" through translucent page. Unfortunately, I can see UIWebView borders when I scroll over its end/beginning edges.

有任何官方苹果资源/网页,说明背景-attachment:fixed is not implemented for iOS4?

Is there any official Apple resource/web page stating that background-attachment: fixed is not implemented for iOS4?

干杯!

上述代码段:

<style type="text/css">  
body {  
    background: #ffffff url('image.jpg') fixed no-repeat;  
    background-attachment: fixed;  
}  
</style>


推荐答案

我不知道CSS是怎么回事并没有机会检查它自己,但我知道,当我试图摆脱UIWebView的阴影我使用这一点的代码:

I am not sure what is going on with the CSS and have not had a chance to check it out for myself but I know when I was trying to get rid of the shadows from a UIWebView I used this bit of code:

NSArray *sv = [NSArray arrayWithArray:[myWebView subviews]];
UIScrollView *webScroller = (UIScrollView *)[sv objectAtIndex:0];

NSArray *wsv = [NSArray arrayWithArray:[webScroller subviews]];

[[wsv objectAtIndex:6] setHidden:YES];
[[wsv objectAtIndex:7] setHidden:YES];
[[wsv objectAtIndex:8] setHidden:YES];
[[wsv objectAtIndex:9] setHidden:YES]; 

,它摆脱了阴影。我认为我得到的问题的答案,但当我找到它是唯一的

and it got rid of the shadows. I thought I got the answer off of a SO question but when I looked for it this is the only one that came up.

它通过App Store检查。

It passed App Store inspection.

这篇关于'background-attachment:fixed'的解决方法在iOS4中不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆