Views do have to have an initial size before the autoresizing masks can be 
useful. That means we you create it you have to set the size to something. 
The autoresize mask is used when the parent view changes size. It's useful 
for making views which adapt to things like device rotation or when making 
a custom view with subviews.

They're not magic, but I was able to port an app last year from iPad to 
iPhone with very few changes because I relied on autoresize masks to do 
most of the work. This is also easier if you use interface builder to 
build your UI.

The autolayout features in iOS 6 are more designed for what you originally 
wanted to do, but they are even harder to use in code (as opposed to 
interface builder), so autoresizing masks are still better for the simple 
cases.

I should also point out that you should technically be using View.Bounds 
instead of View.Frame. Bounds and Frame may be in a different coordinate 
system (if, for example, your View has a transform applied to it). You can 
usually get away with it, but if you do start using transforms then you 
may find this code doesn't behave correctly.
--
Adam Kemp
[email protected]
(512) 683-6058

[email protected] wrote on 09/21/2012 04:44:49 PM:

> From: victoria <[email protected]>
> To: [email protected], 
> Date: 09/21/2012 04:44 PM
> Subject: Re: [MonoTouch] Autosize our app for iPhone 5...
> Sent by: [email protected]
> 
> I hate to reply to my own message, but for those of you who, like me, 
keep
> hitting the brick wall and not getting the auto-resizie to work - here's 
the
> answer: Give up, there is no such thing as "magically expand yourself to
> parent size" layout manager style like in CSS, Java Swing, or Most Every
> Other Toolkit Known to Man.
> 
> Instead, what you do is *always* use fixed positioning for everything. 
The
> auto-resize thing only comes in to play when, well, the View is 
*resized*.
> 
> To get your table in a scrollview expand on to the full screen on both
> iPhone4 and 5, and behave accordingly when the in-call status bar is
> toggled, you'd do something like
> 
> // set container to full size of screen, fixed positions ftw
> UIViewScrollView container = new UIScrollView(0,0, View.Frame.Width,
> View.Frame.Height);
> 
> // content size to some large table size
> container.ContentSize = new SizeF(table.Frame.Width, table.Frame.Height)
> 
> // how to resize the scrollview when the status bar is toggled
> container.AutoresizingMask = UIViewAutoresizing.FlexibleHeight
> 
> // add the table
> container.AddSubview(table);
> 
> I hope this helps someone in the future, it would have saved me quite a 
lot
> time :-)
> 
> / Vic
> 
> 
> 
> --
> View this message in context: http://monotouch.
> 
2284126.n4.nabble.com/Autosize-our-app-for-iPhone-5-tp4657080p4657146.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch

_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to