Saturday, March 31, 2012

Upgrade OpenFlowSharp to work with retina display

For those of you using OpenFlowSharp for your MonoTouch apps for iOS and is wondering why it is not displaying retina resolution images the following is the fix to make it work:

In ImageUtils.cs line 81, replace:
UIGraphics.BeginImageContext(size);

with:

if (UIScreen.MainScreen.RespondsToSelector(new Selector("scale")))

{

UIGraphics.BeginImageContextWithOptions(size, false, UIScreen.MainScreen.Scale);

}

else

{

UIGraphics.BeginImageContext (size);

}


You'll need the if block to check for "scale" because it is only supported on iOS 4 and above.

iOS sdk 5.1 CATiledLayer Bug - Draw gets called twice for every tile

Ok I've been banging my head as to why the CATiledLayer Draw(RectF rect) method is being called twice resulting in memory crashes in my monotouch app in sdk 5.1. This used to work in 5.0.1 with no problems i.e. tiles are rendered only once as it should. However once I upgraded to Lion 10.7.3 and ios sdk 5.1, this bug appears and each tile seems to be rendered twice. I can tell from a simple Console.WriteLine(rect) in the Draw method which outputs the coordinates of the tile being drawn.

The reason I discovered this is because my app started to crash with SCGen checked (MonoDevelop iPhone Build/Advanced/Runtime Options). This bug is confirmed in apple's official devforum: https://devforums.apple.com/message/638091

Note: you will need to have a login to view the post.

In the meantime, the workaround is to NOT use SCGen for production build (I am already NOT using it for prod builds anyway, I am only using it for dev builds because it is still experimental) and build against 5.0.1 if you still can.

Hopefully Apple will release a fix soon.

FInally...

Finally I have decided to share with the world all my frustrations and discoveries to do with the development world..