iOS开发之拨打客服电话(UIActionSheet)

1.第一步(把冰箱门打开)

//客服电话     
NSString *hotLineStr = [NSString removerBlankString:self.creditCardModel.hotline];  
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:@"拨打客服热线?"delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:hotLineStr otherButtonTitles:nil];     
[actionSheet showInView:self.view];

2.第二步(把大象放进去)

#pragma mark - UIActionSheetDelegate Method
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex   (NSInteger)buttonIndex {
 if (buttonIndex == 0) {
  NSString *hotLineStr = [NSString removerBlankString:[NSString removerBlankString:self.creditCardModel.hotline]];         
  UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:nil message:hotLineStr delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"呼叫", nil];
  [alertView show];     
 } 
}

3.第三步(把冰箱门盖上)

#pragma mark - UIAlertViewDelegate Method 
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {    
 if (buttonIndex == 1) {
   NSString *hotLineStr = [NSString removerBlankString:[NSString removerBlankString:self.creditCardModel.hotline]];         
   NSString * phoneNumber = [NSString stringWithFormat:@"tel://%@", hotLineStr];
   [[UIApplication sharedApplication] openURL:[NSURL URLWithString:phoneNumber]];     
 }
}

你可能感兴趣的:(iOS开发之拨打客服电话(UIActionSheet))