tags:

views:

363

answers:

2

Hi Guys,

Today I have installed iPhone SDK 3.1 along with appropriate XCode. The thing that happened is that all of my buttons have lost their titles. Here is my code for button creation:

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];

Any ideas what is the problem? This code worked flawlessly in < 2.2 SDKs

Regardz, Mladen

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

UILabels and UITableView cells are now more customizable in 3.0+. I found this directly from looking in the docs for UIButton.

coneybeare
This isn't working
Mladen
Can't call it on the titleLabel... [dateButton setTitle:forState]
DexterW
+1  A: 

Copy and Paste: Should be self explanatory. Behavior changed in SDK 3.x. Cheers, 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];
Jordan
This is it. Thx a lot
Mladen