Why is UITextView contentInset/padding different on simulator vs device?

I'm debugging a strange text wrapping problem on my device that I have tracked down to some kind of modification in the UITextView contentInset value starting in XCode 4.

Here is the sample code I am using to showcase this bug:

NSString *message = @"How are you doing?";
CGSize messageDimensions = [message sizeWithFont:[UIFont systemFontOfSize:15.0]
CGFloat xOffset = 20;
CGFloat yOffset = 20;

CGRect textViewFrame = CGRectMake(xOffset, yOffset, messageDimensions.width+16, messageDimensions.height+16);

self.textView = [[[UITextView alloc] initWithFrame:textViewFrame] autorelease];
self.textView.font = [UIFont systemFontOfSize:15.0];
self.textView.text = message;
self.textView.editable = NO;

[self.view addSubview:self.textView];

Attached are two screenshots running code on the iOS 5 simulator and on my iPhone 4.

Here is the iPhone 4 running iOS5:

Here is the simulator running iOS5.0:

As you can see, it is wrapping in one but not the other. In order to prevent wrapping on my iOS4 device I have to change this line:

CGRect textViewFrame = CGRectMake(xOffset, yOffset, messageDimensions.width+16, messageDimensions.height+16);

To have a padding of +17 not +16.

Can anyone tell me if this is a known bug, and if the UITextView padding amount is a constant value somewhere in UIKit to which I can refer instead of hard-coding it?



Need Your Help

How to disable click jquery when got class 'active'

jquery sizzle

I want to disable clicking when div.button ol.control li has class active.

2 UIView, one single Controller

iphone uiview uiviewcontroller

I have an application composed of a main view and a secondary view which is used to define parameters used by the first view. Both views have their own .xib . In order to simplify the management o...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.