Skip to main content

Posts

Showing posts with the label uialertview

Create UIActionSheet "otherButtons" by passing in array, not varlist

I have an array of strings that I want to use for button titles on a UIActionSheet. Unfortunately, the otherButtonTitles: argument in the method invocation takes a variable length list of strings, not an array. So how I can I pass these titles into the UIActionSheet? The workaround I've seen suggested is to pass nil into otherButtonTitles:, then specify the button titles individually by using addButtonWithTitle:. But this has the problem of moving the "Cancel" button to the first position on the UIActionSheet rather than the last; I want it to be the last one. Is there a way to 1) pass an array in lieu of a variable list of strings, or alternatively 2) move the cancel button to the bottom of the UIActionSheet? Thanks.

Why does my AlertView takes 3 clicks on cancel button to close?

NOTE: I still don't have an answer to this: I implemented a UIAlertView that displays a tableView to make a selection and return to the underlying view controller. The alert view pops up fine, displays all the data and when I click the cancel button it does not respond, then I click it again and it moves position by quarter of an inch, then when I click it for the third time, the alertView finally disappears. What would cause this type of behavior? This is the code: -(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer { CGPoint p = [gestureRecognizer locationInView:self.tableView]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:p]; if (indexPath == nil){ NSLog(@"long press on table view but not on a row"); } else { NSLog(@"long press on table view at row %d", indexPath.row); selectedQuote = [self.quotes objectAtIndex:indexPath.row]; NSLog(@" subject title = %@", selectedQuote.title)

iPhone - How to handle errors at runtime

When writing code, there are many situations that must be treated as runtime errors : an alloc/init returns nil, a resource is not found, a [someClass canDoThis] returns NO for an absolutely-needed feature where YES would be the natural answer, ... For all these situations, I have written an exitWithMessage routine (that displays an alert box), and each class has a kill method that frees allocated memory. So... When in an init method, you have these kind of exceptions, I supposed you could do : [self kill]; [OneClass exitWithFatalErrorMessage]; return nil; - (void) exitWithFatalErrorMessage:(NSString*)message { UIAlertView* alert = [[UIAlertView alloc] initWithTitle:NSLocalizedStringFromTable(@"Error" @"ErrorMessages", @"") message:message delegate:self cancelButtonTitle:NSLocalizedStringFromTable(@"Understood", @"ErrorMessages", @"") otherButtonTitles: nil]; [alert show]; [alert release]; } - (void)alertV