[MonoTouch] EXC_BAD_ACCESS with NSString sizeWithFont:constrainedToSize:lineBreakMode:

Ed Anuff ed at anuff.com
Fri Oct 16 02:55:53 EDT 2009


I'm trying to use the sizeWithFont method in NSString using the
following code.  It works fine on the simulator, but crashes on the
device.  Any thought on how to fix this?


public static SizeF StringSizeWithFontConstrainedToSize(string msg,
UIFont font, SizeF max_size, UILineBreakMode mode)
{
	NSString target = new NSString(msg);
	Selector selector = new Selector
("sizeWithFont:constrainedToSize:lineBreakMode:");
	SizeF size = cgsize_objc_msgSend_IntPtr_cgsize_int(
		target.Handle,
		selector.Handle,
		font == null ? IntPtr.Zero : font.Handle,
		max_size,
		mode);
	return size;
}


More information about the MonoTouch mailing list