将文件写入路径时可以禁用自动旋转吗?

发布于 2024-10-27 08:49:47 字数 916 浏览 8 评论 0原文

在我的应用程序中,我有一个从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

君勿笑 2024-11-03 08:49:47

检查这一点,并在为 true 时将其设置为 BOOL FALSE

if([textView.text writeToFile:newFilePathatomically :YES encoding:NSUTF8StringEncoding error :nil])

{

 isSavingFile = NO:

}

check for this and make you BOOL FALSE when it is true

if([textView.text writeToFile:newFilePath atomically :YES encoding:NSUTF8StringEncoding error :nil])

{

 isSavingFile = NO:

}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文