0
我有动态UIButtons与子视图是UIlabel。 我的要求是第一次在一个按钮上显示一个标签文本,之后根据用户选择(长按按钮)需要更新特定按钮子视图标签文本并删除按钮子视图标签文本的其余部分。如何将Uilabel文本设置为零+ iphone
我试图以这种方式
for (int i=0; i < [arr count]; i++)
{
UILabel *myLbl = [[UILabel alloc] initWithFrame:CGRectMake(30, 70, 60, 21)];
if (myissue.tag ==1) {
myLbl.text = @"Default";
}else {
myLbl.text = @"";
}
myLbl.backgroundColor = [UIColor clearColor];
myLbl.textColor = [UIColor colorWithRed:51.0/255.0 green:51.0/255.0 blue:51.0/255.0 alpha:1.0];
[myLbl setFont:[UIFont fontWithName:@"Helvetica" size:12]];
myLbl.textAlignment = NSTextAlignmentCenter;
myLbl.tag = i+1;
[myButton addSubview:defaultLbl];
[myLbl release];
}
And for retrieving the UILabel text
- (void)longPressTap:(UILongPressGestureRecognizer *)sender
{
if ([recognizer.view tag]) {
for (UIButton *btn in scrollView.subviews) {
UIButton *btnTag = (UIButton *)btn;
NSLog(@"--sv:%@", btn.subviews);
if (recognizer.view.tag == btnTag.tag){
[[btn.subviews objectAtIndex:3] text] ;
}else {
[[btn.subviews objectAtIndex:3] textAttributesForNil] ;
}
}
}
}
}
我的问题是我无法选择的按钮子视图标签文字和按钮标签文本的消除休息。 请帮助我。
肯定的,但在我的要求我有多个UIlabels – temp 2013-03-06 07:27:10
啊,它听起来像一次只有一个标签 – Fonix 2013-03-06 07:28:50