在我的应用程序中,我有一个从 UITextView 写入文件的过程。当进程进行时,我想显示一些警报,以便用户在进程未完成时无法执行任何操作。问题是当保存过程发生然后我旋转设备或模拟器时,一些后台进程受到干扰,所以它使我的应用程序崩溃。
我想也许我必须禁用自动旋转,当这个保存过程发生时。但我不知道该怎么办。我的想法对吗???有人可以帮我这样做吗?
更新
这是我尝试解决此问题的代码段
-(void)showAlertIndicator{
alertSave = [[CustomAlertIndicator alloc] initWithNibName:@"CustomAlertIndicator" bundle:nil];
isSavingFile = YES;
[alertSave show];
[textView.text writeToFile:newFilePath atomically :YES encoding:NSUTF8StringEncoding error :nil];
[self dismissAlertIndicator];
}
-(void)dismissAlertIndicator{
[alertSave dismiss];
isSavingFile = NO;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if (isSavingFile == YES) {
return NO;
}else {
return YES;
}
}
但它仍然不起作用。
谢谢
问候,
里斯玛