UIWebView stops auto scrolling

advertisements

How can I stop my UIWebView from automatically scrolling on the press of a button?

[web_try loadHTMLString:[NSString stringWithFormat:@"<marquee scrollamount='2' direction='up' loop='true' width='278' height='48'> <font size='3' face='HelveticaNeue-Bold' color='#242424'>%@</font></marquee>", option_value] baseURL:final_url];


i think you can use this code to scroll your view and to stop it just works fine for me

-(void)scrollView
{
    NSInteger scroll = 1;
    NSString* javascript = [NSString stringWithFormat:@"window.scrollBy(0, %d);",scroll];
    [self.currentView stringByEvaluatingJavaScriptFromString:javascript];
    if(validateTimer)
    {
        [timer invalidate];
        validateTimer = false;
    }

    timer = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(scrollView) userInfo:nil repeats:YES];
    validateTimer = true;
}

-(IBAction)stopScroll
{
    [timer invalidate];
    validateTimer = false;
    hidden.enabled = FALSE;
}