在我的应用中,我想在UIButton
内添加多个UITextView
,现在我使用单个对象添加UIButton
但我更改任何UIButton
更改适用于所有UIButton
,我是如何解决的?
-(void)Check
{
CGPoint origin = note.frame.origin;
NSString* head = [note.text substringToIndex:note.selectedRange.location];
CGSize initialSize = [head sizeWithFont:note.font constrainedToSize:note.contentSize];
NSUInteger startOfLine = [head length];
NSString* tail = [head substringFromIndex:startOfLine];
CGSize lineSize = [tail sizeWithFont:note.font forWidth:note.contentSize.width lineBreakMode:UILineBreakModeWordWrap];
CGPoint cursor = origin;
cursor.x += lineSize.width+15;
cursor.y += initialSize.height - lineSize.height-130;
myButton=[UIButton buttonWithType:UIButtonTypeCustom];
myButton.frame=CGRectMake(cursor.x, cursor.y, 15, 15);
Chkimg = [UIImage imageNamed:@"unchk.png"];
[myButton setBackgroundImage:Chkimg forState:UIControlStateNormal];
[myButton addTarget:self action:@selector(ChcK) forControlEvents:UIControlEventTouchUpInside];
[note addSubview:myButton];
}
答案 0 :(得分:0)
使用button.tag
属性区分您的所有按钮。
并可以根据tagValue
执行任务if(button.tag==0)
{
//do somthing
}
else
{
//do other thing
}