我试图打开相机,并在屏幕上显示它(在我的视野内),也保持火炬。
我遇到的问题是,这是我第一次运行应用程序,但当应用程序转到后台,然后前景摄像头冻结和显示最后的视图。
测试了我所做的:
我看到其他一些应用程序也有同样的问题。
有没有人知道或能想到一个解决方案?(如果它能在iOS5+上工作,那就足够了)
谢谢。
发布于 2012-05-08 17:29:48
在控制相机和火炬的视图控制器中,向UIApplicationDidBecomeActiveNotification添加一个观察者。
-(void)viewDidLoad {
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(becameActive) name:UIApplicationDidBecomeActiveNotification object:nil];
}
-(void)becameActive {
//this code runs when you resume a suspended application
//turn the camera torch on here
//assuming you already have this code
}
-(void)viewDidUnload {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super viewDidUnload];
}https://stackoverflow.com/questions/10503336
复制相似问题