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];
				}

 

posted @ 2012-06-28 14:22  Season2009  阅读(187)  评论(0编辑  收藏  举报