将文件写入路径时可以禁用自动旋转吗?
在我的应用程序中,我有一个从 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;
}
}
,但它仍然不起作用。
谢谢你的
问候,
里斯玛
in my app i have a process to writting a file from UITextView. When the process on going, i want to display some alert so user can not do anything when the process is not finished. The problem is when the saving process happen and then i rotate the device or the simulator, some background process is disturbed, so it crash my app.
I think maybe i have to disable the autorotation, when this saving process happen. But I dont know what to do. is my idea right??? Can somebody help me to do this??
UPDATE
this is my snippet code to try solving this problem
-(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;
}
}
but it still not works.
Thank you
Regards,
Risma
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
检查这一点,并在为 true 时将其设置为 BOOL FALSE
if([textView.text writeToFile:newFilePathatomically :YES encoding:NSUTF8StringEncoding error :nil])
{
}
check for this and make you BOOL FALSE when it is true
if([textView.text writeToFile:newFilePath atomically :YES encoding:NSUTF8StringEncoding error :nil])
{
}