Add more button at the end of text inside UITextView Objective-C?(在 UITextView Objective-C 内的文本末尾添加更多按钮?)
问题描述
我正在尝试做与此链接中的类似的事情 http://www.oracle.com/webfolder/ux/mobile/pattern/img/expand-collpase-description.png
I am trying to do something similar to the one in this link http://www.oracle.com/webfolder/ux/mobile/pattern/img/expand-collpase-description.png
单击更多"按钮时扩展 UITextView 内的内容.我正在我的 viewDidLoad 中创建按钮,如下所示
Expanding the content inside a UITextView when clicking the button 'more'. I am creating the button in my viewDidLoad like the below
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"more" forState:UIControlStateNormal];
[self.detailPriceView addSubview:button];
从 PFQuery 加载数据后,我正在 UITextView 内设置按钮的框架
I am setting the frame of the button inside the UITextView after loading the data from PFQuery
PFQuery *query = [PFQuery queryWithClassName:self.restaurantName];
[query whereKey:@"ItemName" equalTo:self.item_name];
[query getFirstObjectInBackgroundWithBlock:^(PFObject *itemDataObj, NSError *error) {
if (!error) {
self.detailPriceView.text = [itemDataObj objectForKey:@"PriceDetail"];
self.detailPriceView.text = [self.detailPriceView.text substringToIndex:40];
[button setFrame:self.detailPriceView.frame];
}
}];
如何在文本末尾的 UITextView 中添加更多按钮?我还创建了一个约束以在单击更多按钮时增加它的高度,但我无法将约束的高度增加到超过某个阈值大小.
How to add more button inside UITextView at the end of the text ? Also i created a constraint to increase it's height when the more button is clicked, but i'm unable to increase the constraint's height beyond some threshold size.
推荐答案
我也在做同样的事情.只需将按钮添加到textView.superView,因为textView 是scrollView.在 textView 中使用按钮的矩形作为textView.textContainer.exclusionPaths = [UIBezierPath(rect: rect)]
I'm doing the same thing. Just add the button to textView.superView, because textView is scrollView. Use button's rect in textView as
textView.textContainer.exclusionPaths = [UIBezierPath(rect: rect)]
最后,我做到了.最重要的是 rect
必须在 textView.frame
中包含.
At last, I did it. Most important thing is rect
must be included in textView.frame
.
这篇关于在 UITextView Objective-C 内的文本末尾添加更多按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 UITextView Objective-C 内的文本末尾添加更多按钮?


基础教程推荐
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01