views:

40

answers:

2

Hi Folks,

I am using UIWebView to show a pdf file in my MainViewController. On single tap I want to load a new View to the MainViewController.

But the UIWebView is not allowing default UITouch event

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{

}

How to solve this problem?

Regards

A: 

UIWebView a is subclass of UIScrollView. You can use touchesShouldBegin:withEvent:inContentView: method defined in UIScrollView documentation.

You need to define this method in your UIWebView own class:

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {
// DO SOMETHING
return NO;}
Pierre Valade
A: 

@Pierre

Thanks

I did the following :

@implementation UIViewTouch

. . .

- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view 
{
    // DO SOMETHING
    return NO;
}

In the view controller implementation:

-(void)viewDidLoad
{

    CGRect frame = CGRectMake(0, 0, 500, 1000);     
    UIViewTouch *viewTouch = [[UIViewTouch alloc]initWithFrame:frame];

    NSString *urlAddress = [[NSBundle mainBundle] pathForResource:@"page1" ofType:@"pdf"];  
    NSURL *url = [NSURL fileURLWithPath:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [viewTouch loadRequest:requestObj]; [self.view addSubview:viewTouch];

}
iWasRobot