J'ai un UIScrollView
où je crée deux UIButtons
. Le premier bouton fonctionne comme il se doit, mais le second bouton disparaît. Il est toujours là et peut accepter les clics, et devient visible lorsque vous cliquez sur le bouton caché.UIScrollView et UIButton, UIButtons disparaissent
Des idées sur pourquoi le deuxième bouton apparaît?
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
button_1 = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
button_1.titleLabel.font = [UIFont systemFontOfSize:12];;
button_1.titleLabel.lineBreakMode = UILineBreakModeTailTruncation;
button_1.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
button_1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[button_1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button_1 setTitle:@"Circle" forState:UIControlStateNormal];
button_1.frame = CGRectMake(0.0, 30.00, 50, 20);
[button_1 addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button_1];
button_2 = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain];
button_2.titleLabel.font = [UIFont systemFontOfSize:12];;
button_2.titleLabel.lineBreakMode = UILineBreakModeTailTruncation;
button_2.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
button_2.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[button_2 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[button_2 setTitle:@"Square" forState:UIControlStateNormal];
button_2.frame = CGRectMake(0.0, 120.0, 50, 20);
[button_2 addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];
[cell.contentView addSubview:button_2];
Une autre zone de code est à l'origine du problème. Rien ne va pas avec ce que vous faites dans l'exemple de code (sauf que le retenir n'est pas nécessaire, mais cela ne causera pas votre problème) – bentford