开发者

addSubview modifying the added view's frame

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 an开发者_运维问答d 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜