我的屏幕上有一个 UITextview,我在屏幕上拖放创建了 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];
}
但这不起作用..