Re: shouldAutorotateToInterfaceOrientation not being called ...
Re: shouldAutorotateToInterfaceOrientation not being called ...
- Subject: Re: shouldAutorotateToInterfaceOrientation not being called ...
- From: Jay Reynolds Freeman <email@hidden>
- Date: Mon, 26 Jul 2010 11:35:20 -0700
I have actually made a little progress on this, and hope no one
minds if I ask for more advice. (Failing all else, this long
message may help you sleep ...)
First, as Matt suggested, I did set a breakpoint in the code --
and "shouldAutorotateToInterfaceOrientation" is indeed not being
called. (And breakpoints, logging output, and app behavior
all confirm that the relevant instance of my UIViewController
subclass is being loaded and is running.)
Second, I build an "empty" single-view iPad app as a comparison
case -- just let the Xcode template generate it and added no code
or resources. On setting a breakpoint in that code, I find that
its "shouldAutorotateToInterfaceOrientation" *is* being called,
and the call stack shows that the first call happens deep
within the statement "[window addSubview:viewController.view];",
within the code in the app delegate (constructed by the template)
for "application:didFinishLaunchingWithOptions:". There are
a lot of frames on the stack between "shouldAutorotate ..."
and "addSubview", all of which are for private internals stuff,
so it is hard to break on any of the interim function calls,
or to investigate what is going on in them.
When I break at the "addSubview" line in my misbehaving
app, I can stop there, but any attempt to step into the call
does nothing. It looks like for some reason, in my code,
"addSubview" is not being called, or perhaps it is inlined
and some of the calls that it makes are not being called.
After a little nosing around, I found a possible explanation
for that, that explained some of other problems I have had
but had not mentioned here. My code has the usual two xib
files: The first contains (among other things) the instance of
my subclassed UIViewController; the second contains the actual
instance of UIView that my subclassed UIViewController is
supposed to control. The File's Owner stand-in object in
the second xib file has the same class type as my subclass,
and such of its IBOutlet slots as should point to things in
that second xib file are properly hooked up.
Investigation revealed, however, that though the desired
instance of my subclassed UIViewController was in fact getting
loaded and some of its code is running, the IBOutlets that
I hooked up from the File's Owner in the second xib file,
to the desired objects in that file, were *not* getting
initialized at load- and run-time; they all were ending
up nulls. There is supposed to be a mechanism that tracks
down these links and makes them right in the real instance
of the subclassed UIViewController that is created at
load-time, but that mechanism was not working for me.
After looking at much documentation and checking lots of
things (spellings right, class types declared properly,
IBOutlets all set up as properties with @property and
@synthesize, NIB Name correctly declared in the IB
inspector, et cetera), I simply added a specific load
of the relevant xib file in the code for my app's
"application:didFinishLaunchingWithOptions:", just
before the "addView" wherein the call to
"shouldAutorotateToInterfaceOrientation" should occur.
(The relevant code is
[[NSBundle mainBundle] loadNibNamed:@"Pixie_Scheme_IIIViewController" owner:viewController options:nil];
and I have wrapped it with NSLogs to be sure it runs, checked
it for null return, and so on.)
That code alone was sufficient to cause the null IBObject
links that I mentioned earlier, to be resolved properly at
run time. I have not had to do anything with the NSArray
of top-level objects that it returns, to make that happen.
HOWEVER, "shouldAutorotateToInterfaceOrientation" still
is not getting called.
Any further suggestions or observations?
And anyone who has read through all this deserves my
heartfelt thanks just for doing so ... :-)
-- Jay Reynolds Freeman
---------------------
email@hidden
http://web.mac.com/jay_reynolds_freeman (personal web site)
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden