我正在寻找一种在UIWebView中调试JavaScript的方法,并且特别发现了一些关于_enableRemoteInspector的文章
http://atnan.com/blog/2011/11/17/enabling-remote-debugging-via-private-apis-in-mobile-safari/
我无法获得编译的示例代码.我一直得到一个"没有已知的选择器类方法"错误.不只是一个警告.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//Works
[NSClassFromString(@"WebView") performSelector:@selector(_enableRemoteInspector)];
//Won't compile
//[NSClassFromString(@"WebView") _enableRemoteInspector];
}
Run Code Online (Sandbox Code Playgroud)
所以我尝试了performSelector,它可以工作,调试器按照描述工作.
但是如何在不使用performSelector的情况下编译它?
我正在运行Xcode 4.2.1,我的项目使用iOS5 SDK.
我看到了Bug Me iPhone应用程序,并且对在主屏幕上添加图标的能力很感兴趣.我认为它的工作方式类似于Safari实现它的方式.
这里有一个类似的问题,说不可能: 实现"添加到主屏幕",ala Safari
显然有一种方法,我不是在寻找合适的地方.
还有其他人解决过吗?
我最近尝试将UITextField子类化并将委托设置为我自己(发现这个尝试解决了我的问题:http://www.cocoabuilder.com/archive/cocoa/241465-iphone-why-can-a-uitextfield-be-its -own-delegate.html)
@interface MyObject :UITextField <UITextFieldDelegate>
@end
@implementation MyObject
-(id) initWithFrame:(CGRect) frame
{
if((self=[super initWithFrame:frame]))
{
self.delegate=self;
}
return self;
}
-(BOOL) respondsToSelector:(SEL)selector
{
NSLog(@"responds to selector");
return [super respondsToSelector:selector];
}
// Implement all the missing methods
@end
Run Code Online (Sandbox Code Playgroud)
调用接口上定义的方法会导致无限递归.我在Apple文档中没有看到任何定义在一个委托在场的情况下responsesToSelector应该如何表现的内容.
ios ×2
debugging ×1
delegates ×1
homescreen ×1
iphone ×1
javascript ×1
uitextfield ×1
uiwebview ×1