Iphone uitextview中的按钮
我有一个UIExView,希望有uibutton。当点击该按钮时,我想做一些动作。所以我做了如下操作Iphone uitextview中的按钮,iphone,ios4,Iphone,Ios4,我有一个UIExView,希望有uibutton。当点击该按钮时,我想做一些动作。所以我做了如下操作 UITextView *myTextView = [[UITextView alloc] init]; myTextView.frame = CGRectMake(10, 100, 300, 80); myTextView.layer.borderWidth = 1.0f; myTextView.layer.cornerRadius = 5; myTextView
UITextView *myTextView = [[UITextView alloc] init];
myTextView.frame = CGRectMake(10, 100, 300, 80);
myTextView.layer.borderWidth = 1.0f;
myTextView.layer.cornerRadius = 5;
myTextView.clipsToBounds = YES;
myTextView.layer.borderColor = [[UIColor grayColor] CGColor];
[self.view addSubview:myTextView];
[myTextView sizeToFit];
[myTextView release];
// Create an UIButton
UIButton *pickerBtn = [UIButton buttonWithType: UIButtonTypeCustom];
// Set its background image for some states...
UIImage *pickerImage = [UIImage imageNamed:@"picker.png"];
[pickerBtn setBackgroundImage: pickerImage forState:UIControlStateNormal];
// Add target to receive Action
[pickerBtn addTarget: self action:@selector(showPicker:) forControlEvents:UIControlEventTouchUpInside];
// Set frame width, height
pickerBtn.frame = CGRectMake(-25, -10, 50, 30);
pickerBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
pickerBtn.titleLabel.font = [UIFont boldSystemFontOfSize:13];
pickerBtn.titleLabel.shadowColor = [UIColor colorWithWhite:0.0 alpha:0.5];
pickerBtn.titleLabel.shadowOffset = CGSizeMake(0, -1);
pickerBtn.bounds = CGRectInset(button.bounds, -3, 2);
pickerBtn.titleLabel.textColor = [UIColor whiteColor];
[myTextView addSubview:pickerBtn];
但我的问题是,即使在那个按钮上,光标也会显示出来
有没有更好的方法来做我现在正在尝试的事情
请让我知道并感谢您必须测量文本的长度,将按钮放在文本的末尾,然后单击“显示选择器”并附加文本。我想这就是你可以做的。你能提供一个屏幕截图来帮助解释你的问题吗?你到底想做什么?@jrturton:添加了图像和thanks@HardikShah:单击该btn时,我想显示要选择的选择器,所选文本将附加到textviewOne中,光标位于按钮顶部会很好;)。对于文本视图来说,它看起来很短,是否允许多行编辑?