UITextView 或 UIWebView:如何显示简单的可编辑 TXT 文件的页面

发布于 2024-10-20 14:27:06 字数 414 浏览 2 评论 0原文

我想要的只是一个全屏的简单文本编辑器。但是,我不想要滚动组件,而是让用户轻拂页面(而不是滚动)。所以我需要导入或打开 TXT,然后通过制动来格式化它(例如通过将其内容划分为每屏/页 10 行)。

我的问题是如何显示txt? UITextView 是可滚动的(尽管我可以在 IB 中禁用它)...我没有找到 UIWebView 的任何方法来让它在不同的“页面”或屏幕上格式化我的内容。

我需要从哪里开始? 理想情况下,我需要一些示例代码。 UIWebView 的所有示例都没有告诉我有关如何在多个页面上设置可编辑文本格式的任何信息。

所以我真正想要的是一个不可滚动的 UITextView,如果我在第一页/屏幕上的空间不足,它会打开一个新页面/屏幕。

感谢您为我入门提供的任何帮助。

All I want to have is a full-screen simple text editor. However, I don't want the scrolling component, but rather let the user flick through the pages (instead of scrolling). So I need to import or open a TXT and then format it by braking it down (e.g. by dividing its contents to 10 lines per screen/page).

My question is how I will display the txt? UITextView is scrollable (even though I can disable this in IB)... I did not find any method for UIWebView to let it format my contents on different 'pages' or screens.

Where will I need to start? Ideally I'd need some sample code. All the samples for UIWebView do not tell me anything about how to format editable text on several pages.

So all I really want is an UITextView which is not scrollable and opens up a new page/screen if I run out of space on the first page/screen.

Thanks for any help to get me started.

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

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

发布评论

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

评论(2

要走就滚别墨迹 2024-10-27 14:27:06

首先……没有特定的方法可以实现这一点

1.您需要将单个字符串分解为多个字符串,为此您可以使用

  int pageNumber; // suppose this keep track of on what page you are
  int count; //suppose this keep track of how long string your one screen support
  NSString* completeString; //suppose this is your string
  NSRange range = NSMakeRange(pageNumber * count, count);
  NSString* temp = [completeString substringWithRange:range];

2.Now 而不是使用 UITextView (如果您不想用户交互)你应该使用 UILable
只需更改 UILabel 的属性(这是您感兴趣的)

UILabel* myLabel; //suppose this is that label
myLabel.numberOfLines = 0; //this will chage your label to go multyline.

first thing first ...... there is no particular method to achieve this

1.You need to break your single string into multiple strings, to do that you can use

  int pageNumber; // suppose this keep track of on what page you are
  int count; //suppose this keep track of how long string your one screen support
  NSString* completeString; //suppose this is your string
  NSRange range = NSMakeRange(pageNumber * count, count);
  NSString* temp = [completeString substringWithRange:range];

2.Now instead of using UITextView (if you don't want user interaction ) you should use UILable
just change the property of UILabel (this one is of your interest)

UILabel* myLabel; //suppose this is that label
myLabel.numberOfLines = 0; //this will chage your label to go multyline.
生生漫 2024-10-27 14:27:06

您应该能够通过将 UITextView 放入 UIScrollView 并将 UIScrollView 上的 pagingEnabled 设置为 YES 来实现此目的。

You should be able to achieve this by putting your UITextView into a UIScrollView and setting pagingEnabled on the UIScrollView to YES.

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