The WkWebView's loaded contents is responsible for the navigation inside, usually done with javascript or the default scrolling behaviour of webviews.
While WKWebView
is a inherited class from NSView
you can do all stuff with it that is possible with the super class.
so you can call
[self.mapview resizeSubviewsWithOldSize:NSZeroSize];
or/and
- (BOOL)canBecomeFirstResponder {
return YES;
}
can be set.
You could also explicit define how interaction is handled.
The following example code was meant to be able to turn off a (bool)_cursor value to stop cursor interactions of a wkwebview.
#pragma mark - interaction interception
- (NSView*)hitTest:(NSPoint)point {
if (_cursor) return [super hitTest:point];
return nil;
}
- (void)keyDown:(NSEvent *)event {
[super keyDown:event];
}
- (void)keyUp:(NSEvent *)event {
[super keyUp:event];
}
-(void)mouseMoved:(NSEvent *)event {
if (_cursor) [super mouseMoved:event];
}
- (void)mouseDown:(NSEvent *)event {
if (_cursor) [super mouseDown:event];
}
- (void)mouseUp:(NSEvent *)event {
if (_cursor) [super mouseUp:event];
}
- (void)mouseDragged:(NSEvent *)event {
if (_cursor) [super mouseDragged:event];
}
- (void)mouseEntered:(NSEvent *)event {
if (_cursor) [super mouseEntered:event];
}
- (void)mouseExited:(NSEvent *)event {
if (_cursor) [super mouseExited:event];
}
But there is a much simpler way.
You don't need UIPanGestureRecognizer
when you implement the NSResponder protocol or use the corresponding methods for Views..
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
// do stuff
[super touchesBegan:touches withEvent:event];
}
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
// do stuff;
}
[super touchesMoved:touches withEvent:event];
}
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
for (UITouch *touch in touches) {
// do stuff;
}
[super touchesEnded:touches withEvent:event];
}
and last but not least..
just in case you missed the definition of your selector
your WKWebView needs the following @implementation
-(void)panningMethod:(UIPanGestureRecognizer *)gesture {
}
and usually also the @interface definition
-(void)panningMethod:(UIPanGestureRecognizer *)gesture;
and finally you do not need to call the explicit -setDelegate
method after definition of a GestureRecogniser unless you meant to set the -navigationDelegate
for the WKWebView
.