-1

I have a UITableViewController which creates dynamically re-sizeable cells. The cell changes the size of the cell depending on the text content and the font size. (A tip found here.)

It uses a call to the following method which is deprecated:

cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease]; 

I have not been able to figure out which method to use instead and keeping my functionality. There is no reference in the Apple documentation.

How could I solve this?

Johan Karlsson
  • 1,136
  • 1
  • 14
  • 37
  • See also [initWithFrame : reuseIdentifier : is deprecated](http://stackoverflow.com/questions/6967506/initwithframe-reuseidentifier-is-deprecated) – Brad Larson Feb 06 '12 at 19:28

3 Answers3

2

The documentation specifically states:

Deprecated in iOS 3.0. Use initWithStyle:reuseIdentifier: instead.

Jim
  • 72,985
  • 14
  • 101
  • 108
  • I searched _initWithFrame_ and I found the wrong _initWithFrame_, where I found no reference to this information. My bad :( – Johan Karlsson Jan 31 '12 at 07:32
1

Try something like this.

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Standard"];
if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Standard"] autorelease];
}
jrtc27
  • 8,496
  • 3
  • 36
  • 68
MrWaqasAhmed
  • 1,479
  • 12
  • 12
1
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
Mehul Mistri
  • 15,037
  • 14
  • 70
  • 94