views:

104

answers:

1

I'm not sure how to ask this question, but here goes...

I am rendering a PDF page into a view and adding it to a UIViewController. Works fine, except for some PDF files.

For some reason, the code goes through a different path for certain PDF files. It happens when the PDF is created from PowerPoint. After the addSubview call, it goes through a path that alters the PDF view's frame. I added an observer for PDFViewController.view.frame and the trace goes:

0 -[PDFViewController observeValueForKeyPath:ofObject:change:context:]
1 NSKVONotify
2 -[NSKeyValueObservance observeValueForKeyPath:ofObject:change:context:]
3 NSKVONotify
4 -[NSObject(NSKeyValueObserverNotification) didChangeValueForKey:]
5 _NSSetRectValueAndNotify
6 -[UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]
7 -[UIView(Internal) _didMoveFromWindow:toWindow:]
8 -[UIView(Hierarchy) _postMovedFromSuperview:]
9 -[UIView(Internal) _addSubview:positioned:relativeTo:]
10 -[UIView(Hierarchy) addSubview:]
11 (rest of trace is expected)

For most PDF files, this works ok. But for some, the added view's frame gets modified somewhere in [UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]. The y coordinate of the origin moves down by 43 pixels and the height is decreased by around 20%. I can't find any information about what happens inside that method, it appears to be internal to UIViewController.

Anyone have any idea why the frame is being modified? At least a nudge in the right direction?

Thanks in advance.

EDIT:

Now I'm pretty sure that it is [UIViewController viewDidMoveToWindow:shouldAppearOrDisappear:]that is screwing it up. I implemented an empty -viewDidMoveToWindow:(UIWindow *)shouldAppearOrDisappear:(BOOL)flag method in PDFViewController and the bug went away. But this just doesn't look like a fix, but instead may lead to a rejected app. >.<

Anyone with any suggestions/comments?

A: 

43px is size of navigationbar. Do you have it?

GameBit
Yeah, but it's an extra 43px below the nav bar. Also, isn't the nav bar height 44px instead of 43px? Anyway, the fix for this problem is found here --> http://stackoverflow.com/questions/3708961/overriding-internal-uiviewcontroller-methods-because-an-internal-method-is-giving
Altealice
Accepting answer to close this. Actual fix in http://stackoverflow.com/questions/3708961/overriding-internal-uiviewcontroller-methods-because-an-internal-method-is-giving.
Altealice