HTML marquee not working in iOS 5.1

2019-05-08 16:25发布

Please see below function.

-(void)loadHTMLinWebView
{   
    objWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
    objWebView.opaque = NO;
    objWebView.userInteractionEnabled = NO;
    objWebView.backgroundColor = [UIColor clearColor];
    NSString *strTemp = @"<html><body style="margin-top:0px; margin-left:0px; text-align:center"><marquee behavior="alternate" style="font-family:Marker Felt;font-size:20px; color:#A52A2A;">Test</marquee></font></body></html>";
    [objWebView loadHTMLString:strTemp baseURL:nil];
    [self addSubview:objWebView];
}

Above is the code that I had written for loading HTML in UIWebView.

But when I am running this code in iOS 4.0 device, It is working well and I saw marquee effect in Webview but running this code in iOS 5.1 device, It is not showing the marquee effect, It is just showing the text.

Don't know what is happening there.

Please help me to solve this problem.

Thanks in advance.

2条回答
霸刀☆藐视天下
2楼-- · 2019-05-08 16:51
放我归山
3楼-- · 2019-05-08 16:54

Checking your code I found that behavior="alternate" is causing problem to stop scrolling. If you put behavior="scroll" than it will scroll but not as per your requirement.

If you look for alternates than there is other answer which may be helpful to you.

Here are few links to discussion which discuss this problem and recommends not to use marquee.

link1 link2 link3

Update

Wowo ! This is something interesting. I checked again and found that it does work but not for small strings. It works for somewhat large strings. Still no clue about the problem.

查看更多
登录 后发表回答