我正在使用委托方法;
-(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视图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)