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.
AS alternative you can create same thing with UIView and Timer. Please refer below URL
https://github.com/jeffhodnett/JHTickerView
https://github.com/MugunthKumar/MKTickerViewDemo
https://github.com/caydenliew/CLTickerView
Checking your code I found that
behavior="alternate"
is causing problem to stop scrolling. If you putbehavior="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.