在 UITextView Objective-C 内的文本末尾添加更多按钮?

Add more button at the end of text inside UITextView Objective-C?(在 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 内的文本末尾添加更多按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Why local notification is not firing for UNCalendarNotificationTrigger(为什么没有为UNCalendarNotificationTrigger触发本地通知)
iOS VoiceOver functionality changes with Bundle Identifier(IOS画外音功能随捆绑包标识符而变化)
tabbar middle tab out of tabbar corner(选项卡栏中间的选项卡角外)
Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How can I sync two flatList scroll position in react native(如何在本机Reaction中同步两个平面列表滚动位置)
Get an event when UIBarButtonItem menu is displayed(显示UIBarButtonItem菜单时获取事件)