tirsdag 22. november 2011

Beware of layers in iOS!

When working a MonoTouch application, I got a design that involved transparency, rounded corners and shadows. I was happy to discover that this could all be done via the layers property so I added a utility method:

public static void ApplyDropShadow (UIButton imgView)
{
  imgView.Layer.ShadowColor = UIColor.FromRGB (0, 0, 0).CGColor;
  imgView.Layer.ShadowOffset = new SizeF (2, 2);
  imgView.Layer.ShadowOpacity = 1f;
  imgView.BackgroundColor = UIColor.Clear;
  imgView.Layer.ShadowRadius = 1.0f;
  imgView.Layer.BorderColor = UIColor.White.CGColor;
  imgView.Layer.BorderWidth = 0.7f;
  imgView.Layer.CornerRadius = 2f;
  imgView.Layer.MasksToBounds = true;
  imgView.ClipsToBounds = false;
}
but this yielded "horrible" scrolling performance. Took me a good many hours to discover the cause of the "jerky" scrolling, but the shadow part was the culprit.

As a temporary solution the shadows are now gone, and I am now looking at doing this using CoreGrahics. Some sample code for MonoTouch can be found here: 
http://sabonrai.wordpress.com/2009/09/03/monotouch-sample-core-graphics-and-uiimageview/

objective-c: http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/

Another option is to buy an iPhone 4gs as the scrolling is silky smooth on this device.
Fragmentation! :-)

tirsdag 15. november 2011

Automating building of iOS apps

After 3 days of struggle and cursing I finally was able to automate our build process of iOS apps.

Since the scripts ended up as not very clean (for now) then I just want to point out the articles that helped me along the way:

For setting up the build script:
http://blog.carbonfive.com/2011/05/04/automated-ad-hoc-builds-using-xcode-4/

For automating Beta Builder
http://blog.flirble.org/2010/10/16/app-ad-hoc-beta-publishing/

Using those two scripts in combination and remembering to set the FTP transfer to binary (argh!) finally produced one beautiful looking IPA file that worked on my iPad! Now I just need to automate our Android apps but I suspect that will be much easier :-)