Inoperative Cancel button in UIActionSheet

Let’s say you want to use UIActionSheet to show three buttons to the user with a cancel buttons in a UIView, which itself is managed by a UITabBarController:

Your code would probably look like this:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@”Action Title” delegate:self cancelButtonTitle:@”Cancel” destructiveButtonTitle:nil otherButtonTitles:@”Option 1″@”Option 2″@”Option 3″nil];

actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

[actionSheet showInView:self.view];

[actionSheet release];

And you’ll also probably find that all the 3 option buttons works, but the Cancel one doesn’t!
It is because the UIView which the UIAlertSheet belongs to is behind the UITabBarController, and the TabBar’s hitTest method gets called before the UIAlertSheet’s.
To fix this, it is just a simple matter of using the view from the UITabBarController in the showInView method. Like this:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@”Action Title” delegate:self cancelButtonTitle:@”Cancel” destructiveButtonTitle:nil otherButtonTitles:@”Option 1″@”Option 2″@”Option 3″nil];

actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

UIApplicationDelegate *appDelegate = (UIApplicationDelegate *)[[UIApplication sharedApplication] delegate];

UITabBarController *tabBarController = appDelegate.tabBarController;

[actionSheet showInView:tabBarController.view];

[actionSheet release];

Time Machine Error

WTF? Almost on par with some of the Windows error message:

Read and post comments |
Send to a friend

Two days later

While lying in bed this morning (actually more like late morning/noon) the blog post idea that escape me last week suddenly popped into my head! So now it is safely jotted down in my Mac, waiting to be fully flushed out.

Read and post comments |
Send to a friend

QotD: OS Preference

Windows, Mac, Linux – What's your preference and why?
Submitted by ramblingsbymark.

I prefer Mac as a day-to-day OS/Computer. Not that Windows are bad, I use it everyday for 8+ hours for work, and Microsoft has made developing software on Windows really easy and enjoyable. Apple's Xcode is ok but it is nothing like Visual Studio or even Eclipse. But the fact remains that Windows are not secure, must require running of anti-virus/anti-spyware software in the background, requires constant vigilant to make sure it is not infected, etc. makes using a Mac so much more less stressful and enjoyable.

The last time I tried Linux was nearly 10 years ago and even with these intervening years I still think Linux has not evolved into the point where any consumers can install and use it without knowledge of *nix.

OS X is really Linux done right.

Read and post comments

|

Send to a friend