Come indicato nel post Apple iPhone SDK 3.0: prime incompatibilità le SDK 3.0 di Apple mostrano comportamenti differenti rispetto alla release 2.2.1. Il supporto di assistenza per gli sviluppatori mi ha fornito la risposta, e quindi la soluzione al problema. La risposta del supporto tecnico è stata che [UIButton buttonWithType:] già chiama – al suo interno – la initWithFrame. Ne deriva che, sempre secondo il supporto tecnico, scrivendo:
1 | UIButton *myButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] initWithFrame:CGRectMake(0, 0, 100, 40)]; |
Si invoca la initWithFrame due volte, causando la perdita del testo label. In pratica basta sostituire il codice sopra con:
1 2 | UIButton *myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; myButton.frame = CGRectMake(0, 0, 100, 40); |
La risposta originale:
1 2 3 | +[UIButton buttonWithType:] already calls initWithFrame: for you. Calling it twice erases internal information that causes the problem you see with the disappearing text. Code changes in 3.0 revealed the bug. In your code, just say: UIButton * restart_button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; restart_button.frame = CGRectMake(40,430,100,40); |








7
Non ci sono commenti per questo Post
Lascia un commento