好的,经过测试,您似乎需要将 声明NSUserActivity
为实例变量:
所以这不起作用:
@interface TestViewController () {
}
@end
@implementation TestViewController
- (void)viewDidLoad {
[super viewDidLoad];
//init hand off
NSUserActivity *activity = [[NSUserActivity alloc] initWithActivityType:@"com.app.browse"];
activity.webpageURL = [NSURL URLWithString:@"http://www.stackoverflow.com"];
[activity becomeCurrent];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
但这很好用:
@interface TestViewController () {
NSUserActivity *activity;
}
@end
@implementation TestViewController
- (void)viewDidLoad {
[super viewDidLoad];
//init hand off
activity = [[NSUserActivity alloc] initWithActivityType:@"com.app.browse"];
activity.webpageURL = [NSURL URLWithString:@"http://www.stackoverflow.com"];
[activity becomeCurrent];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
不知道为什么,我现在正在研究