I am having the worst time trying to figure out why I cannot get the following code to output the correct width. When I use the following code to get the width it works fine and outputs 232. In this code I hard code in the string.
But if I use the following from an NSMutable Array and NSMutable string from the array I get a width of 352. What is going on here?
Code:
UILabel *labelDescription = [[UILabel alloc] init];
labelDescription.font = [UIFont boldSystemFontOfSize:12];
labelDescription.text = @"The Rise of Middle-of-the-Road Radicals";
CGSize size = [labelDescription.text sizeWithFont:labelDescription.text constrainedToSize:CGSizeMake(290, 32) lineBreakMode:UILineBreakModeWordWrap];
Code:
NSLog(@"%@", [NSNumber numberWithInt:size.width]);
But if I use the following from an NSMutable Array and NSMutable string from the array I get a width of 352. What is going on here?
Code:
UILabel *labelDescription = [[UILabel alloc] init];
labelDescription.font = [UIFont boldSystemFontOfSize:12];
NSMutableArray *cellTitleArray1 = [finalArraySortArrayElements2 objectAtIndex:indexPath.section];
NSMutableArray *cellTitleArray2 = [cellTitleArray1 objectAtIndex:indexPath.row];
labelDescription.text = [cellTitleArray2 objectAtIndex:0];
CGSize size = [labelDescription.text sizeWithFont:labelDescription.text constrainedToSize:CGSizeMake(290, 32) lineBreakMode:UILineBreakModeWordWrap];
Code:
NSLog(@"%@", [NSNumber numberWithInt:size.width]);