UIActionSheet & UIAlertView
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"您是否真的要发邮件给他?" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Yes" otherButtonTitles:nil]; [actionSheet showInView:self.view]; [actionSheet release];
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { SendMailViewController *detailViewController = [[SendMailViewController alloc] init]; detailViewController.emailAddress = [dict objectForKey: @"Email"]; [[self navigationController] pushViewController:detailViewController animated:YES]; [detailViewController release]; } }
NSString* webPage = [dict objectForKey: @"WebPage"]; NSURL* url = nil; if ([webPage length] == 0 ) { return; } if( [webPage hasPrefix:@"http://"]) { url = [NSURL URLWithString:webPage]; } else { NSString* fullWebPage = [NSString stringWithFormat:@"http://%@",webPage]; url = [NSURL URLWithString:fullWebPage]; } if ([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; } else { UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Cannot open page" message:@"网址有误,或网络暂时不能访问" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; }
签名:删除冗余的代码最开心,找不到删除的代码最痛苦!