一、设置软键盘为时间选择器
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
self.indexPath = indexPath;
//获取当前点击的cell
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
//为了点击cell的时候能弹出键盘
//生成文本框,并且让文本框成为第一响应者
UITextField *txt = [UITextField new];
[cell addSubview:txt];
//设置键盘的工具栏
CZKeyboard *tool = [CZKeyboard keyboardTool];
tool.delegate = self;
txt.inputAccessoryView = tool;
//弹出datePicker
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
self.datePicker = datePicker;
datePicker.datePickerMode = UIDatePickerModeTime;
datePicker.backgroundColor = [UIColor lightGrayColor];
//把弹出键盘改成datePicker
txt.inputView = datePicker;
//让文本框成为第一响应者,此处之前 应该先设置inputView
[txt becomeFirstResponder];
}
二、自定义后退按钮位置调整
//如果tableView启用分组的话。第一组之前会有空白。把空白去掉
self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, -1)];
```
//1 自定义后退按钮
UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[[UIImage imageNamed:@"NavBack"] originalImage] style:UIBarButtonItemStylePlain target:self action:@selector(backClick)];
// 后退按钮距离图片距离左边边距
UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];
fixedItem.width = -10;
self.navigationItem.leftBarButtonItems = @[fixedItem,backItem];
//自定义后退按钮后,手势返回上一级控制器的功能恢复
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
```
三、NSInterger格式问题
%ld
%d
%zd 根据当前系统判断返回类型 64位 32位
四、电话分享、短信分享、邮件分享
__weak typeof(self) weakSelf = self;
CZItem *item1 = [CZItemArrow itemWithTitle:@"电话分享" icon:nil option:^{
//通话完成会回到当前应用, 以前的时候不会回到当前应用
// NSURL *url = [NSURL URLWithString:@"tel://54188"];
// [[UIApplication sharedApplication] openURL:url];
//打电话之前会有提示 回到当前应用 私有的api
// NSURL *url = [NSURL URLWithString:@"telprompt://54188"];
// [[UIApplication sharedApplication] openURL:url];
NSURL *url = [NSURL URLWithString:@"tel://54188"];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[weakSelf.webView loadRequest:request];
}];
CZItem *item2 = [CZItemArrow itemWithTitle:@"短信分享" icon:nil option:^{
//发完短信之后。会到短信界面
// NSURL *url = [NSURL URLWithString:@"sms://54188"];
// [[UIApplication sharedApplication] openURL:url];
//判断设备是否能发送信息
if (![MFMessageComposeViewController canSendText]) {
return;
}
MFMessageComposeViewController *vc = [MFMessageComposeViewController new];
//收件人列表
vc.recipients = @[@"10000",@"10086"];
vc.body = @"推荐一个nb的游戏 http://www.nlcoder.com/test";
vc.subject = @"biaoti";
//设置代理
vc.messageComposeDelegate = weakSelf;
[weakSelf presentViewController:vc animated:YES completion:nil];
}];
CZItem *item3 = [CZItemArrow itemWithTitle:@"邮件分享" icon:nil option:^{
//判断是否能发送邮件
if (![MFMailComposeViewController canSendMail]) {
return;
}
MFMailComposeViewController *vc = [MFMailComposeViewController new];
vc.mailComposeDelegate = weakSelf;
//设置收件人
[vc setToRecipients:@[@"1111@itcast.cn",@"2222@itcast.cn"]];
//密送
// [vc setBccRecipients:<#(NSArray *)#>]
//抄送
// [vc setCcRecipients:<#(NSArray *)#>]
[vc setSubject:@"收福利了"];
[vc setMessageBody:@"送美女" isHTML:NO];
//
UIImage *img = [UIImage imageNamed:@"aa"];
NSData *data = UIImagePNGRepresentation(img);
[vc addAttachmentData:data mimeType:@"image/png" fileName:@"cls.png"];
[weakSelf presentViewController:vc animated:YES completion:nil];
}];
//controller(self) --> self.groups --> group --> item --> option --> self
CZGroup *group = [CZGroup groupWithItems:@[item1,item2,item3]];
self.groups = @[group];
五、Demos下载
应用推荐Demos下载地址:
http://git.oschina.net/changyou/MyRecommendProductsDemo/repository/archive/master第一次启动新特性Demo
http://git.oschina.net/changyou/MyNewsFeatureDemo/repository/archive/master
如果你能够在某个领域全身心投入一万个小时,那么你一定是那个领域的专家。