Monday, May 20, 2013

Fixed the Position of UiWebView Scrolling in iOS

Here in this Example i will show you how to restrict the movement of scrollbar in UiWebView at particular point.

We have to set delegate of UiWebView scroll to call UiScrollView Method.

Let Start.
.h


#import <UIKit/UIKit.h>

#import "AsyncImageView.h"

@interface RSSDetailViewController : UIViewController <UIWebViewDelegate,UIScrollViewDelegate>
@property (nonatomic, retain) IBOutlet UIWebView *webViewLink;

@end

.m

@synthesize webViewLink;
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.webViewLink.scrollView.delegate=self;
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    NSLog(@"scrolling vertically; %f",scrollView.contentOffset.y);
    if(scrollView.contentOffset.y> 52)
    {
        CGPoint offSet=scrollView.contentOffset;
        offSet.y=52;
        [scrollView setContentOffset:offSet];
    }
}

IT will restrict the UiWebView scroll at point when it reach to 52

No comments:

Post a Comment