我的屏幕上有一个 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];
}
但这行不通..
最佳答案
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/