要制作呼叫按钮,我可以按如下方式编写代码:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setTitle:@"Respring" forState:UIControlStateNormal];
btn.frame = CGRectMake(100,50,120,100);
[btn addTarget:self action:@selector(buttonPushed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
}
- (void)buttonPushed:(id)sender
{
system("killall -9 SpringBoard");
return;
}
但要制作重启按钮,它似乎无法做到这一点。 我应该写什么代码?
答案 0 :(得分:0)
尝试做这样的事情:
- (void)buttonPushed:(id)sender
{
[[UIApplication sharedApplication] reboot];
return;
}
我在一个找到here的示例项目中尝试了这个并且它有效。我将模板的调用替换为
[[UIApplication sharedApplication] relaunchSpringBoard];
带
[[UIApplication sharedApplication] reboot];