在UITextView中创建一个UIbutton和UIImageview [英] Create a UIbutton and UIImageview in UITextView
本文介绍了在UITextView中创建一个UIbutton和UIImageview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的屏幕上有一个UITextview,我在屏幕上拖放创建了textview,现在我想在textview的最后(文本视图中的文本结尾)添加按钮,然后该怎么做? /p>
我一直在尝试
[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];
}
但这不起作用..
解决方案
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.
I have a UITextview in my Screen,I created textview in drag and drop on screen, now i want to add button to last (end of the text in text view )of the textview then how can i do that ??
i have been try
[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];
}
but that not work ..
解决方案
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.
这篇关于在UITextView中创建一个UIbutton和UIImageview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文