Note that there are some explanatory texts on larger screens.

plurals
  1. POpresentViewController:animated:completion: always results in two instance of the presented view controller, is it a bug?
    primarykey
    data
    text
    <p>I hooked into the presented view controller's init, loadView, viewDidLoad, viewWillAppear:, viewDidAppear:, viewDidUnload and dealloc method to log out relevant timing info.</p> <p>But it was found that whether <code>presentModalViewController:animated:</code> or <code>presentViewController:animated:completion:</code> will result in two instance of the presented view controller and one of them will soonly be destroyed without anything appeared on screen(loadView and next method hasn't been fired yet).</p> <p>Is it a bug or iOS' view controller transition just works like this?</p> <p>Here is the log info, WDIMMindItemEditViewController is the presented view controller and WDIMMainScreenViewController is the presenting view controller:</p> <blockquote> <p>2012-09-29 16:10:02.615 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b5260> :editing view controller will initialize</p> <p>2012-09-29 16:10:02.639 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b5260> :editing view controller initialized</p> <p>2012-09-29 16:10:02.641 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b94d0> :editing view controller will initialize</p> <p>2012-09-29 16:10:02.645 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b94d0> :editing view controller initialized</p> <p>2012-09-29 16:10:02.835 ideaCal[23450:707] &lt; WDIMMainScreenViewController: 0x27c790> will present modal view controller: &lt; WDIMMindItemEditViewController: 0x2b5260></p> <p>2012-09-29 16:10:02.841 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b5260> :editing view controller load view</p> <p>2012-09-29 16:10:02.910 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b5260> :editing view controller has loaded view</p> <p>2012-09-29 16:10:02.912 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b5260> :editing view controller's view will appear</p> <p>2012-09-29 16:10:03.297 ideaCal[23450:707] &lt; WDIMMainScreenViewController: 0x27c790> will present modal view controller: &lt; WDIMMindItemEditViewController: 0x2b94d0></p> <p>2012-09-29 16:10:03.302 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b94d0> :editing view controller will dealloc</p> <p>2012-09-29 16:10:03.340 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b94d0> :editing view controller ended dealloc</p> <p>2012-09-29 16:10:03.702 ideaCal[23450:707] &lt; WDIMMindItemEditViewController: 0x2b5260> :editing view controller's view appeared</p> <p>2012-09-29 16:10:05.434 ideaCal[23450:707] &lt; WDIMMainScreenViewController: 0x27c790> ended present modal view controller: &lt; WDIMMindItemEditViewController: 0x2b5260></p> </blockquote> <p>And here is my presenting code:</p> <pre><code>- (IBAction)slidingMenuGetPressed:(WZUICircularPagingControlViewSlidingMenu *)slidingMenu event:(UIEvent *)event { WDIMEditViewController * editModalViewController = nil; if ([slidingMenu.identifier isEqualToString:NEW_MIND_ITEM]) { editModalViewController = [[WDIMMindItemEditViewController alloc] init]; } if ([slidingMenu.identifier isEqualToString:NEW_PROJECT]) { editModalViewController = [[WDIMMindItemEditViewController alloc] init]; } if ([slidingMenu.identifier isEqualToString:NEW_TAG]) { editModalViewController = [[WDIMTagEditViewController alloc] init]; } dispatch_queue_t snapshotQueue = dispatch_queue_create("com.WeZZardDesign.ScreenSnapshotQueue", NULL); dispatch_async(snapshotQueue, ^{ UIGraphicsBeginImageContextWithOptions(self.view.bounds.size, self.view.opaque, 0.0); [self.view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage * snapshot = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); dispatch_async(dispatch_get_main_queue(), ^{ editModalViewController.backgroundImage = snapshot; NSManagedObjectContext * workingContext = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; workingContext.parentContext = self.database.managedObjectContext; editModalViewController.preference = self.preference; editModalViewController.dataSource = self; editModalViewController.delegate = self; editModalViewController.workingContext = workingContext; NSLog(@"%@ will present modal view controller: %@", self, editModalViewController); [self presentViewController:editModalViewController animated:YES completion:^{ NSLog(@"%@ ended present modal view controller: %@", self, editModalViewController); }]; }); }); dispatch_release(snapshotQueue); } </code></pre> <p>And I have got nothing changed in <code>presentModalViewController:animated:</code> and <code>presentViewController:animated:completion:</code> method.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload