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

标签 iphone objective-c ios ios5 uitextview

我的屏幕上有一个 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/

相关文章:

iphone - 如何让ui始终响应并进行后台更新?

ios - UIWebView 将加载一个 URL 而不是另一个

objective-c - 以编程方式显示相机快门?

ios - AVAudioPlayer 不播放声音,报错

objective-c - 在越狱设备上使用 loadNibNamed 时可能会崩溃 [UIDeviceRGBColor superview] : unrecognized selector

ios - 出于安全原因,如何在iOS中从内存中删除字符串?甚至需要它还是iOS自己处理

iphone - 在 UIView 中绘制垂直线

iphone - iOS6 AVAudioPlayer - AAC 音频文件持续时间始终返回 0

iphone - 删除 armv7s xCode 4.6 有效架构项目属性如何影响我的 iOS 应用程序的 App Store 分发?

iphone - 如何仅隐藏/禁用第一个 uinavigationbar?