iPad programming using first printing


#1

I downloaded the first printing of this book from Amazon for the Kindle Reader in my iPad and I am extremely satisfied with the book.

In fact, the very nature of this first edition not being explicitly geared towards the iPad has forced me to delve into the depths of the user documentation and made some modifications of homepwner, (for clarity, perhaps I’ll call it homepwn3r) implementing UIPopoverController (and its delegate) without any guide to follow.

I noticed a peculiar behaviour with the popup window (which I linked to the camera button) - if I tapped outside the popup window on the screen, naturally the popover controller was dismissed; I have it set now so it dismisses when a photo is selected, however an added bonus is if I tap the camera button twice (or more) a new popover controller is launched which overlays the one already present; so when I tap outside the popover controller, the topmost one is dismissed, leaving the underlying one up, until I tap outside on the screen again.

I fixed this by explicitly dismissing any active popover controllers when the camera button is pressed, but I’m curious if this is the recommended (and taught) implementation by the authors.

Thanks!


#2

Yup, that’s probably the best choice - tapping on a button that opens up a popover while that popover is on the screen should probably hide the popover. I imagine your code looks a bit like this:

if([imagePickerPopover isPopoverVisible])
{
     [imagePickerPopover dismissPopoverAnimated:YES];
     return;
}
...
[imagePickerPopover presentFromBarButtonItem:...];

#3

[quote=“JoeConway”]Yup, that’s probably the best choice - tapping on a button that opens up a popover while that popover is on the screen should probably hide the popover. I imagine your code looks a bit like this:

if([imagePickerPopover isPopoverVisible]) { [imagePickerPopover dismissPopoverAnimated:YES]; return; } ... [imagePickerPopover presentFromBarButtonItem:...]; [/quote]

I didn’t actually use the if statement, I simply called the dismissPopoverAnimated method, on the theory that if there’s no popOver visible, then it would just ignore the message to dismiss it. The trade-off between adding the if statement and simply calling the method may be in processor time; or in good programming practise.