您的位置:首页 > 移动开发

iPhone开发技巧之私有API--- UIApplication

2012-03-13 18:49 531 查看
如果我们继承了UIApplication,就可以捕捉到应用程序发生的各种事件。首先,像下面这样实现你的 main 方法。

int main(int argc, char *argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, @"MyApplication", @"MyAppDelegate");
[pool release];
return retVal;
}

UIApplicationMain 函数的第三个参数中放入继承的UIApplication类名称。第四个参数是委托类(UIApplicationDelegate)的名称。

只要你重载了该类中的函数,就可以hook许多有用的事件。比如下面的方法:

- (void)applicationWillSuspend;

我们可以重载一些私有的API,来实现一些特殊的处理。你可以查看这里得到更多信息。

比如点击了状态条的事件。

- (void)statusBarMouseDown:(struct __GSEvent *)fp8;
- (void)statusBarMouseDragged:(struct __GSEvent *)fp8;
- (void)statusBarMouseUp:(struct __GSEvent *)fp8;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  iphone struct fp hook api