-1

UIButton在我的应用程序中,我喜欢在 a中添加多个UITextView,现在我UIButton使用单个对象添加,但我更改了任何UIButton它更改适用于 all 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];
}
4

1 回答 1

0

使用button.tag属性来区分您的所有按钮。

并且可以根据tagValue执行任务

if(button.tag==0)
{
//do somthing
}
else
{
//do other thing
}
于 2012-12-15T12:19:08.827 回答