tags:

views:

487

answers:

1

I've just found exactly same question but answers mostly connected to problem workaround...
Is this fact (for me it looks like a bug) so obvious(or well-known) that peoples do not even try to find explanation?

In case this is really well-known bug in SDK... Can somebody share his experience about most famous bugs in iPhone SDK (up to 2.2.1 FW)? It would be very useful to collect them and avoid needless questions.

Returning back to discussed issue...
I'm still interested: Is parentViewController always a Navigation controller? (in described conditions: similar question at SO)

I've built same controllers sequence at my app and was confused.

Apple doc told us:

parentViewController
The underlying view controller if this view controller is a modal view controller; otherwise, the enclosing navigation or tab bar controller. nil if none of these are present. (read-only)
UIViewController Class Reference

In our case we have underlying view controller but nevertheless received navigation controller. So what is it? Do we have same value at navigationController and parentViewController?

Thank you, Mike/

+1  A: 

parentViewController is not always a navigationController. Here's a case where it's not:

MyViewController *aViewController = [[MyViewController alloc] init];

UIScrollView *aScrollView = [[UIScrollView alloc] init];

[aScrollView addSubview:aViewController.view];

aViewController.parentViewController==aScrollView; //returns yes

The parentViewController is the most immediate view controller above the current view controller in the hierarchy. In some cases this can be a navigation controller, but it need not be.

Dan Lorenc
Thank you for your answer! Is your app (you quoted from) include Navigation Controller at all?I will try to repeat your sample later in evening my time.Anyway thank you!
MikZ
I've tried same sequence and get nil as parentViewController and it looks right.parentViewController is UIViewController type but UIScrollView is UIView derived.
MikZ