iOS开发笔记-7

拨打电话的三种方法

  1. 这种方法,拨打完电话回不到原来的应用,会停留在通讯录里,而且是直接拨打,不弹出提示
1
2
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxx6979"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];
  1. 这种方法,打完电话后还会回到原来的程序,也会弹出提示,推荐这种
1
2
3
4
5
6
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"tel:%@",@"186xxxx6979"];
UIWebView * callWebview = [[UIWebView alloc] init];
[callWebview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:str]]];
[self.view addSubview:callWebview];
[callWebview release];
[str release];
  1. 这种方法也会回去到原来的程序里(注意这里的telprompt),也会弹出提示
1
2
NSMutableString * str=[[NSMutableString alloc] initWithFormat:@"telprompt://%@",@"186xxxx6979"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]];

底部弹出视图

项目中的底部弹出视图使用的ZZActionSheet

具体使用方法:

  • 引入头文件和协议

import "ZZActionSheet.h"

@interface ViewController ()< ZZActionSheetDelegate>

  • 点击按钮触发底部弹出框:
1
2
3
4
5
6
7
8
9
//底部弹出框
ZZActionSheet *actionSheet =
[[ZZActionSheet alloc] initWithTitle:nil
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:nil
otherButtonTitles:self.telArray];
actionSheet.tag = 0;
[actionSheet showInView:self.view];
  • 实现协议
1
2
3
4
#pragma mark - ZZActionSheetDelegate
- (void)ZZActionSheet:(ZZActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
//buttonIndex就是从上到下按钮的index
}