Friday, September 24, 2010

Stupid UIAlertView Tricks: Part I

Note: This blog is deprecated. @synthesize zach has moved to a new home, at zpasternack.org. This blog entry can be found on the new blog here. Please update your links.

Earlier this evening I was answering a StackOverflow question about putting a UITextView onto a UIAlertView.  I had done this before with UITextFields (I wrote a post about it), but I'd never tried it before with a UITextView.  Well, it turns out to totally work (see my answer here, if you care).

However, it got me thinking about jamming random other views into a UIAlertView.  The logical conclusion of which was this:  StackOverflow in a UIAlertView.


Why?  I dunno.  Cool though, right?

- (void) doAlertViewWithWebView {
 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"stackoverflow" 
             message:@"\n\n\n\n\n\n\n\n\n\n\n\n"
               delegate:nil 
            cancelButtonTitle:nil
            otherButtonTitles:@"OK", nil];
 
 UIWebView *myView = [[[UIWebView alloc] initWithFrame:CGRectMake(10, 40, 264, 254)] autorelease];
 myView.scalesPageToFit = YES;
 [alert addSubview:myView];
 
 [myView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.stackoverflow.com"]]];
 
 [alert show];
 [alert release]; 
}

1 comment: