如何在 iPhone 的 Uitextview 中保存文本

发布于 2024-10-09 07:29:29 字数 158 浏览 0 评论 0原文

笔记作为导航基础应用程序中的 UITextView。如何在写入笔记后保存文本数据。如何识别从键盘返回。需要设置任意键返回备注。我需要存储设备。当用户在注释中输入文本时,第二次之后也可以看到上一页,如果可能的话,请写入上一页的行尾以开始附加。请发布一些教程链接,因为我对这个主题不太了解,我需要理解概念。

Notes as a UITextView in navigation base application .How to save text data after writing in notes .How to identify return from keyboard. need to set any key for return Notes.I need to store device. When user enter the text in notes , after second time able to see previous page also, if its possible write to previous page end of line to start that is appended. plz post some tutorial link , because i am not much about this topic, i need ti understand concept .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

能怎样 2024-10-16 07:29:29

创建在单击按钮时调用的函数,测试用户是否按下 Enter 键,或者测试用户是否从 UITextView 上移除焦点:

-(IBAction)saveText
{

获取要创建的文件的路径:

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:@"savedText.txt"];

从 UITextView 中获取文本(替换 textView与您的 UITextView 的名称):

NSString *savedString = textView.text;

将字符串写入文件:

    [savedString writeToFile:documentTXTPath atomically:YES];
}

Create function that is called on a button click, test if the user has hit enter, or test if the user has removed focus from the UITextView:

-(IBAction)saveText
{

Get the path to the file you want to create:

NSArray *documentPaths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *documentsDirectory = [documentPaths objectAtIndex:0];
NSString *documentTXTPath = [documentsDirectory stringByAppendingPathComponent:@"savedText.txt"];

Get the text from the UITextView (replace textView with the name of your UITextView):

NSString *savedString = textView.text;

Write the string to the file:

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