gpt4 book ai didi

iphone - 在 UITextView 中创建一个 UIbutton 和 UIImageview

转载 作者:行者123 更新时间:2023-11-28 17:59:49 26 4
gpt4 key购买 nike

我的屏幕上有一个 UITextview,我在屏幕上拖放创建了 textview,现在我想将按钮添加到 textview 的最后一个( TextView 中文本的末尾)然后我该怎么做??

我已经尝试过了

[super viewDidLoad];
SelectInvestiList = [[NSMutableArray alloc] initWithCapacity:[InvestiList count]];


AppDelegate *appDeleg = (AppDelegate *)[[UIApplication sharedApplication]delegate];

textViewInvest.text=nil;

UIButton*button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setFrame:CGRectMake(0, 0, 30, 30)];
[button setTitle:@"test" forState:UIControlStateNormal];
[textViewInvest addSubview:button];

NSMutableString *prev=[[NSMutableString alloc] init];
if (appDeleg.chiefCompText != nil) {
prev=(NSMutableString *) textViewInvest.text;
[prev appendString:(NSMutableString *) appDeleg.chiefCompText];
textViewInvest.text=[prev capitalizedString];

}

if (appDeleg.vitalText != nil) {
prev=(NSMutableString *)textViewInvest.text;
[prev appendString:(NSMutableString *) appDeleg.vitalText];
textViewInvest.text=[prev capitalizedString];

}

但这行不通..

最佳答案

enter image description here

    UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[btn setFrame:CGRectMake(0, 0, 10, 20)];
[btn setTitle:@"Ram" forState:UIControlStateNormal];
//[self.view addSubview:btn];
[textview addSubview:btn];
set the button frame according to your text in textview.

关于iphone - 在 UITextView 中创建一个 UIbutton 和 UIImageview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10104356/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com