
You use it pretty much the same way you use an alert view. You allocate and initialize it, call show and then release it:
AlertPrompt *prompt = ;
prompt = ;
;
;Then, you implement the appropriate UIAlertView callback method, and grab the entered text from the alert view instance. You have to cast the alert view back to an AlertPrompt instance, but other than that, everything is the same as using a standard UIAlertview:
- (void)alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex
You can download a sample project that shows how it works right here.
Note: to those of you wondering if this violates the HIG, or will cause problems during review - I don't think it should. Apple does this themselves when they prompt you for a WiFi network password, and I have not used any private APIs or functions whatsoever. I just subclassed an existing public class and extended its functionality in a way that's commonly done.
The code for the class follows:
AlertPrompt.h
//
// AlertPrompt.h
// Prompt
//
// Created by Jeff LaMarche on 2/26/09.
AlertPrompt.m
//
// AlertPrompt.m
// Prompt
//
// Created by Jeff LaMarche on 2/26/09.
0 comments:
Post a Comment