Re: rotating UIView without changing size
On Sat, 04 Aug 2012 00:39:43 +0700, Gerriet M. Denkmann gerr...@mdenkmann.de said: If I understand this correctly, I have to do: create a view controller for my basicView (currently there is none) and use [ basicViewController addChildViewController: sliderViewController ] and not use [ self addSubview: self.sliderView ]; Anything else I have to do? Any sample code, where I could study this? Any documentation I should read (about the containment API)? Any WWDC videos I should watch? The View Controller Programming Guide for iOS says: The area each view controller fills is determined by its parent. But how? Sorry to come in so late here, but it happens that the view hierarchy and the view controller hierarchy and how they must fit together is one of the things that is particularly well explained in my book, and you can even read the relevant chapter online: http://www.apeth.com/iOSBook/ch19.html m. -- matt neuburg, phd = m...@tidbits.com, http://www.apeth.net/matt/ A fool + a tool + an autorelease pool = cool! Programming iOS 5! http://shop.oreilly.com/product/0636920023562.do ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: rotating UIView without changing size
On Aug 3, 2012, at 8:34 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: I have a subclass of UIViewController which displays a small view in the center of the display. shouldAutorotateToInterfaceOrientation: returns YES. The problem: when I rotate the device, the centered view rotates as it should. But it also changes its size to full-screen. The (bad) workaround: in didRotateFromInterfaceOrientation: I set the frame back to a sensible value. Result: when I rotate the device, the view rotates, blows up to fill the screen, then snaps back to its real size. Is there a way to tell the ViewController to NOT mess with the size of its view (it should just exchange width and height)? I'm confused between your two claims. Above you say you have a view controller that displays a small view in the center of the screen. Below you say that this is the view controller's view (that is, the view assigned to the 'view' property). If both of these are true, then you've violated some expectation of UIKit. From the sounds of it, it is the one that expects that a view controller's consumes the entire screen (at least in the absence of view controller containment). If you want a simple view in the center of the screen with a fixed size, then the simplest way to do so is to make that view a subview of the view controller's view. If you set the autoresizingMask correctly, then that view won't be resized at all, and should maintain its position in its superview (if nothing else ensuring the subview remains at the correct size and position should be much easier than what it seems you are trying to do above). -- David Duncan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: rotating UIView without changing size
On 3 Aug 2012, at 22:50, David Duncan wrote: On Aug 3, 2012, at 8:34 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: I have a subclass of UIViewController which displays a small view in the center of the display. shouldAutorotateToInterfaceOrientation: returns YES. The problem: when I rotate the device, the centered view rotates as it should. But it also changes its size to full-screen. The (bad) workaround: in didRotateFromInterfaceOrientation: I set the frame back to a sensible value. Result: when I rotate the device, the view rotates, blows up to fill the screen, then snaps back to its real size. Is there a way to tell the ViewController to NOT mess with the size of its view (it should just exchange width and height)? I'm confused between your two claims. Above you say you have a view controller that displays a small view in the center of the screen. Below you say that this is the view controller's view (that is, the view assigned to the 'view' property). There is a view (which fills the screen, let's call it basicView). When the user taps the screen, the small view - the view controller's view (that is, the view assigned to the 'view' property) - is shown in the middle of the screen. And this small centered view does rotate, when the device is rotated. The basicView does not rotate. If you want a simple view in the center of the screen with a fixed size, then the simplest way to do so is to make that view a subview of the view controller's view. If you set the autoresizingMask correctly, then that view won't be resized at all, and should maintain its position in its superview (if nothing else ensuring the subview remains at the correct size and position should be much easier than what it seems you are trying to do above). The autoresizingMask contains only dashed lines. The code in basicView (an UIView) is: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if ( self.sliderView == nil ) // load nib { NSBundle *mainBundle = [ NSBundle mainBundle ]; SliderViewController *tem = [ [ SliderViewController alloc ] initWithNibName:@Sliders bundle: mainBundle biGroup: biGroup cubeGlView: self ]; self.sliderViewController = tem; [ tem release ]; self.sliderView = self.sliderViewController.view; self.sliderView.center = self.center; [ self addSubview: self.sliderView ]; } self.sliderView.hidden = NO; } Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: rotating UIView without changing size
On Aug 3, 2012, at 9:16 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: The code in basicView (an UIView) is: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if ( self.sliderView == nil ) // load nib { NSBundle *mainBundle = [ NSBundle mainBundle ]; SliderViewController *tem = [ [ SliderViewController alloc ] initWithNibName:@Sliders bundle: mainBundle biGroup: biGroup cubeGlView: self ]; self.sliderViewController = tem; [ tem release ]; self.sliderView = self.sliderViewController.view; self.sliderView.center = self.center; [ self addSubview: self.sliderView ]; } self.sliderView.hidden = NO; } As I alluded to earlier, if you are going to use view controller containment, you MUST use the containment API if you want sane behavior. The reason you are getting this behavior is that based on your greater conditions, the SliderViewController you just created is getting rotation callbacks, and since it doesn't have a parent view controller would assume it is a full screen view controller and sizes itself for that. I would recommend you either 1) adopt view controller containment and do this addition in the view controller that owns basicView (which needs to be a subclass to do this properly) of 2) make SliderViewController not a subclass of UIViewController. -- David Duncan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: rotating UIView without changing size
On 3 Aug 2012, at 23:59, David Duncan wrote: On Aug 3, 2012, at 9:16 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: The code in basicView (an UIView) is: - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { if ( self.sliderView == nil ) // load nib { NSBundle *mainBundle = [ NSBundle mainBundle ]; SliderViewController *tem = [ [ SliderViewController alloc ] initWithNibName:@Sliders bundle: mainBundle biGroup: biGroup cubeGlView: self ]; self.sliderViewController = tem; [ tem release ]; self.sliderView = self.sliderViewController.view; self.sliderView.center = self.center; [ self addSubview: self.sliderView ]; } self.sliderView.hidden = NO; } As I alluded to earlier, if you are going to use view controller containment, you MUST use the containment API if you want sane behavior. The reason you are getting this behavior is that based on your greater conditions, the SliderViewController you just created is getting rotation callbacks, and since it doesn't have a parent view controller would assume it is a full screen view controller and sizes itself for that. I would recommend you either 1) adopt view controller containment and do this addition in the view controller that owns basicView (which needs to be a subclass to do this properly) of If I understand this correctly, I have to do: create a view controller for my basicView (currently there is none) and use [ basicViewController addChildViewController: sliderViewController ] and not use [ self addSubview: self.sliderView ]; Anything else I have to do? Any sample code, where I could study this? Any documentation I should read (about the containment API)? Any WWDC videos I should watch? The View Controller Programming Guide for iOS says: The area each view controller fills is determined by its parent. But how? 2) make SliderViewController not a subclass of UIViewController. If I use this alternative (might be easier to fit into my code) - how do I get notified of device rotations? Kind regards, Gerriet. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: rotating UIView without changing size
On Aug 3, 2012, at 10:39 AM, Gerriet M. Denkmann gerr...@mdenkmann.de wrote: 1) adopt view controller containment and do this addition in the view controller that owns basicView (which needs to be a subclass to do this properly) of If I understand this correctly, I have to do: create a view controller for my basicView (currently there is none) and Modern iOS programming expects a view controller to be present (and this explains why when you add the view controller you get the behaviors you do). Since you don't have a view controller at all currently, then my recommendation would be to create a base view controller, install all of your controls into it at startup, and hide the ones that are on demand. This is far simpler than the approaches I outlined (which expected that you already had a view controller) and anything else you can do. (for all interested observers) Don't try to get away with not having a view controller (that is explicitly set as the window's rootViewController). Its simply not worth it. -- David Duncan ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com