如何重建EMail-App文本样式?

发布于 2024-12-01 05:14:11 字数 637 浏览 1 评论 0原文

我想要一个文本发送视图,就像苹果电子邮件应用程序中的发送电子邮件视图一样。 (默认的 iPhone 电子邮件应用程序)。

我尝试了带有 2 个 TextFields 和 1 个 TextView 的 UIScrollView,但看起来不太好,滚动视图没有功能,并且当我在 TextView 中输入文本时视图不会滚动(当我键入时,文本隐藏在第三行中。)这

是一张图片: http://s3.imgimg.de/uploads/Bildschirmfoto20110823um1156940f792556940f791456940f79png.png

它应该看起来像这样: http://a5.mzstatic.com/us/r1000/032/Purple/ea/4f/03/mzl.bxracfen.320x480-75.jpg

如何重建?

I want to have a text-send view like the send-email view from the email app by apple. (the default iPhone emailapp).

I tried a UIScrollView with 2 TextFields and 1 TextView, but it looks not good, the scrollview has no function and the view does not scroll when I enter a text in the TextView (the text is hiding in the third line when I type...

Here is a picture:
http://s3.imgimg.de/uploads/Bildschirmfoto20110823um1156940f792556940f791456940f79png.png

It should look like this:
http://a5.mzstatic.com/us/r1000/032/Purple/ea/4f/03/mzl.bxracfen.320x480-75.jpg

How to rebuild?

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

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

发布评论

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

评论(1

乖乖兔^ω^ 2024-12-08 05:14:11

当您开始在 UITextfield 中写入文本时,要向下滚动,请使用以下方法:

   [yourScrollView scrollRectToVisible:CGRectMake(yourTextfield.frame.origin.x,yourTextField.frame.origin.y,yourScrollView.frame.size.width,yourScrollView.frame.size.height) animated:YES];    

此外,当您编辑 TextView 时(即在 textViewDidBeginEditing 方法中),请将其框架缩小,以便使其完全可见。然后,当您完成编辑文本(即在 textViewDidEndEditing 方法中)时,将框架设置为原来的样子。

编辑:

//add this in .h file
     NSInteger originalHeight;

//in .m file
- (void) textViewDidBeginEditing:(UITextView *)textView
{
       [yourScrollView scrollRectToVisible:CGRectMake(yourTextView.frame.origin.x,yourTextView.frame.origin.y,yourScrollView.frame.size.width,yourScrollView.frame.size.height) animated:YES];  

       //now set the frame
       //you just need to change the height, rest can be kept whatever they are
       //set the newHeight so as to make the textview visible

       originalHeight = yourTextView.frame.size.height;
       yourTextView.frame = CGRectMake(x,y,width,newHeight);

       //rest of the code
}

现在编辑完成后,将高度设置为之前的高度。

- (void) textViewDidEndEditing:(UITextView *)textView
{
       yourTextView.frame = CGRectMake(x,y,width,originalHeight);
}

to scroll downside when you start writing the text inside UITextfield, use this :

   [yourScrollView scrollRectToVisible:CGRectMake(yourTextfield.frame.origin.x,yourTextField.frame.origin.y,yourScrollView.frame.size.width,yourScrollView.frame.size.height) animated:YES];    

Also, when you edit your TextView (i.e in the textViewDidBeginEditing method), make its frame smaller so as to make it fully visible. Then, when you finish editing the text (i.e in the textViewDidEndEditing method) set the frame to whatever it was, originally.

EDIT:

//add this in .h file
     NSInteger originalHeight;

//in .m file
- (void) textViewDidBeginEditing:(UITextView *)textView
{
       [yourScrollView scrollRectToVisible:CGRectMake(yourTextView.frame.origin.x,yourTextView.frame.origin.y,yourScrollView.frame.size.width,yourScrollView.frame.size.height) animated:YES];  

       //now set the frame
       //you just need to change the height, rest can be kept whatever they are
       //set the newHeight so as to make the textview visible

       originalHeight = yourTextView.frame.size.height;
       yourTextView.frame = CGRectMake(x,y,width,newHeight);

       //rest of the code
}

Now when editing is completed, set the height to as it was before.

- (void) textViewDidEndEditing:(UITextView *)textView
{
       yourTextView.frame = CGRectMake(x,y,width,originalHeight);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文