ios - Dismissing QLPreviewController crashes: Auto Layout still required -


i working on ipad app splitviewcontroller. in detailviewcontroller, there button used present qlpreviewcontroller , show document. works fine far, however, when dismiss preview controller using done button on top left, app throws exception following error:

*** assertion failure in -[uiview layoutsublayersoflayer:], /sourcecache/uikit_sim/uikit-2380.17/uiview.m:5781 *** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'auto layout still required after sending -viewdidlayoutsubviews view controller. detailviewcontroller's implementation needs send -layoutsubviews view invoke auto layout.' *** first throw call stack: (...) libc++abi.dylib: terminate called throwing exception 

here how implemented presentation of qlpreviewcontroller , delegate methods:

- (ibaction)previewbuttonpressed:(id)sender {     qlpreviewcontroller *ql = [[qlpreviewcontroller alloc] init];     ql.datasource = self;     ql.delegate = self;     ql.currentpreviewitemindex = 0;     [self presentviewcontroller:ql animated:yes completion:null]; }  - (id <qlpreviewitem>)previewcontroller:(qlpreviewcontroller *)controller previewitematindex:(nsinteger)index {     return [nsurl fileurlwithpath:self.documentfilepath]; }  - (nsinteger) numberofpreviewitemsinpreviewcontroller: (qlpreviewcontroller *) controller {     return 1; } 

and viewdidlayoutsubviews:

- (void)viewdidlayoutsubviews {     [super viewdidlayoutsubviews];     [self.scrollview setcontentsize:self.gridview.frame.size]; // if not called, contentsize of uiscrollview wrong. } 

detailviewcontroller contains uiscrollview , has custom uiview (gridview) subview , gridview has many subviews.

while testing, commented out line of code sets content size viewdidlayoutsubviews, , doing so, dismiss preview controller. however, works before add gridview subview scrollview. after adding subview, crashes again on dismissal. time exc_breakpoint error , no log on console. output debugger follows:

corefoundation`cfhash: 0x4597740:  pushl  %ebp 0x4597741:  movl   %esp, %ebp 0x4597743:  pushl  %edi 0x4597744:  pushl  %esi 0x4597745:  subl   $16, %esp 0x4597748:  calll  0x459774d                 ; cfhash + 13 0x459774d:  popl   %edi 0x459774e:  movl   8(%ebp), %esi 0x4597751:  testl  %esi, %esi 0x4597753:  jne    0x459776b                 ; cfhash + 43 0x4597755:  int3    0x4597756:  calll  0x46eca00                 ; symbol stub for: getpid  <-  exc_breakpoint (code=exc_i386_bpt, subcode=0x0) 0x459775b:  movl   %eax, (%esp) 0x459775e:  movl   $9, 4(%esp) 0x4597766:  calll  0x46eca4e                 ; symbol stub for: kill ... 

as note, app targeting ios 6 , using auto layout.

i wonder if can me resolve issue. in advance.

in viewdidlayoutsubviews implementation, error message tells do: call [self.view layoutsubviews]. see if helps.

edit: may suggestion in preceding paragraph should call layoutifneeded rather layoutsubviews.

another thing try, if doesn't work: move whole content size setting thing viewwilllayoutsubviews instead of doing in viewdidlayoutsubviews.


Comments

Popular posts from this blog

ios - iPhone/iPad different view orientations in different views , and apple approval process -

java Extracting Zip file -

C# WinForm - loading screen -