2009-09-21 4 views
1

Aujourd'hui, j'ai installé iPhone SDK 3.1 avec XCode approprié. La chose qui est arrivée est que tous mes boutons ont perdu leurs titres. Voici mon code pour la création de bouton:SetTitle pour les boutons dans l'iPhone SDK> 3.0

UIButton *dateButton = [[UIButton buttonWithType:UIButtonTypeRoundedRect] initWithFrame:CGRectMake(240.0, 57.0, 60.0, 30.0)]; 
     [dateButton setTitle:@"Date" forState:UIControlStateNormal]; 
     [dateButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
     [dateButton setBackgroundImage:[UIImage imageNamed:@"bg_headline.png"] forState:UIControlStateNormal]; 
     [dateButton addTarget:self action:@selector(GoToDateSettings:) forControlEvents:UIControlEventTouchUpInside]; 
     [self.view addSubview:dateButton]; 

Des idées quel est le problème? Ce code a fonctionné parfaitement dans < 2.2 SDKs

Regardz, Mladen

Répondre

3

Copier-coller: Devrait être explicite. Comportement changé dans SDK 3.x. Vive, Jordan

 UIButton *dateButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
     [dateButton setFrame:CGRectMake(240.0, 57.0, 60.0, 30.0)]; 
     [dateButton setTitle:@"Date" forState:UIControlStateNormal]; 

     [dateButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 
     [dateButton setBackgroundImage:[UIImage imageNamed:@"bg_headline.png"] forState:UIControlStateNormal]; 
     [dateButton addTarget:self action:@selector(GoToDateSettings:) forControlEvents:UIControlEventTouchUpInside]; 
     [self.view addSubview:dateButton]; 
+0

Ce qu'il est. Merci beaucoup – Mladen

-1
[dateButton.titleLabel setTitle:@"Date" forState:UIControlStateNormal]; 

UILabels et les cellules uitableview sont maintenant personnalisables à 3.0+. Je l'ai trouvé directement en regardant dans les documents pour UIButton.

+0

Ce ne fonctionne pas – Mladen

+0

ne peut pas appeler sur le TitleLabel ... [dateButton setTitle: forState] – DexterW