cocoa-touch – iPad UIWebView在href链接坐标上定位UIPopoverController视图

cocoa-touch – iPad UIWebView在href链接坐标上定位UIPopoverController视图,第1张

概述我希望这个问题不是一个愚蠢的问题,但是如何在UIWebView上定位UIPopoverController视图,以便d出视图箭头指向被点击以显示它的UIWebView链接? 我正在使用委托方法; -(BOOL) webView:(UIWebView *)inWeb shouldStartLoadWithRequest:(NSURLRequest *)inRequest navigationType 我希望这个问题不是一个愚蠢的问题,但是如何在UIWebVIEw上定位UIPopoverController视图,以便d出视图箭头指向被点击以显示它的UIWebVIEw链接?

我正在使用委托方法;

-(BOol) webVIEw:(UIWebVIEw *)inWeb shouldStartLoaDWithRequest:(NSURLRequest *)inRequest navigationType:(UIWebVIEwNavigationType)inType {if ( [[[inRequest URL] absoluteString] hasPrefix:@"myscheme:"] ) {//UIPopoverController stuff herereturn NO;}

}

捕获和路由点击但我不确定如何获得链接坐标定位d出视图.

任何帮助或指向相关信息的指针都将非常感激.

解决方法 我有一个有效的解决方案,但我认为有更好的方法.

我创建了一个从UIWebVIEw继承的touchableWebVIEw,并在方法hitTest中保存触摸位置.之后,您需要为webvIEw设置委托并实现方法-webVIEw:shouldStartLoaDWithRequest:navigationType:

touchableWebVIEw.h:

@interface touchableWebVIEw : UIWebVIEw {CGPoint lasttouchposition;}@property (nonatomic,assign) CGPoint lasttouchposition;

touchableWebVIEw.m:

// I need to retrIEve the touch position in order to position the popover- (UIVIEw *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{    self.lasttouchposition = point;    return [super hitTest:point withEvent:event];}

在RootVIEwController.m中:

[self.touchableWebVIEw setDelegate:self];// WebVIEw delegate,when hyperlink clicked- (BOol)webVIEw:(UIWebVIEw *)webVIEw shouldStartLoaDWithRequest:(NSURLRequest *)request     navigationType:(UIWebVIEwNavigationType)navigationType {    if (navigationType == UIWebVIEwNavigationTypelinkClicked)     {           CGPoint touchposition = [self.vIEw convertPoint:self.touchableWebVIEw.lasttouchposition fromVIEw:self.touchableWebVIEw];        [self displayPopOver:request atposition:touchposition isOnCelebrityFrame:FALSE];        return FALSE;    }    return TRUE;}

这不好,因为UIWebView的文档说你不应该继承它.我想有一个更好的方法,但这确实有效.你找到了另一种解决方案吗

总结

以上是内存溢出为你收集整理的cocoa-touch – iPad UIWebView在href链接坐标上定位UIPopoverController视图全部内容,希望文章能够帮你解决cocoa-touch – iPad UIWebView在href链接坐标上定位UIPopoverController视图所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1081088.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存