Handle taps within a UIWebView

by alex 2. January 2012 08:57

//1. Add UIGestureRecognizerDelegate to your interface:

 

@interface DocumentViewControler : UIViewController <UIGestureRecognizerDelegate>

 

//2. Add to viewDidLoad

 

- (void)viewDidLoad {

    [super viewDidLoad];

    

    

    UITapGestureRecognizer* singleTap=[[UITapGestureRecognizer

                                        alloc]initWithTarget:self action:@selector(handleSingleTap:)];

    singleTap.numberOfTouchesRequired=1;

    singleTap.delegate=self;

    [self.webView addGestureRecognizer:singleTap];

    [singleTap release];

}

 

//3. Add:

 

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer

shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer

                                                    *)otherGestureRecognizer {

    return YES;

}

 

//4.

 

-(void) handleSingleTap:(UITapGestureRecognizer *)recognizer  {

    NSLog(@"handleSingleTap");

    

    // Your code here

}

@end

Show file included into project in UIWebView

by alex 22. February 2010 16:33

NSString *path = [NSString stringWithString:[[NSBundle mainBundle] pathForResource:@"feedback" ofType:@"html"]];

webView.opaque = NO;

webView.backgroundColor = [UIColor clearColor];

[webView setDelegate:self];

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path isDirectory:NO]]];


Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen