系統(tǒng)盤(pán)datePicker、調(diào)整Nav后退按鈕位置調(diào)整,電話短信郵件分享

一、設(shè)置軟鍵盤(pán)為時(shí)間選擇器

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
self.indexPath = indexPath;
//獲取當(dāng)前點(diǎn)擊的cell
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

//為了點(diǎn)擊cell的時(shí)候能彈出鍵盤(pán)
//生成文本框,并且讓文本框成為第一響應(yīng)者
UITextField *txt = [UITextField new];
[cell addSubview:txt];

//設(shè)置鍵盤(pán)的工具欄
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];

//把彈出鍵盤(pán)改成datePicker
txt.inputView = datePicker;

//讓文本框成為第一響應(yīng)者,此處之前 應(yīng)該先設(shè)置inputView
[txt becomeFirstResponder];
}

二、自定義后退按鈕位置調(diào)整

//如果tableView啟用分組的話。第一組之前會(huì)有空白。把空白去掉
 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];



//自定義后退按鈕后,手勢(shì)返回上一級(jí)控制器的功能恢復(fù)
self.navigationController.interactivePopGestureRecognizer.delegate = nil;
```

三、NSInterger格式問(wèn)題

%ld
%d
%zd 根據(jù)當(dāng)前系統(tǒng)判斷返回類型 64位 32位

四、電話分享、短信分享、郵件分享

  __weak typeof(self) weakSelf = self;
    
    CZItem *item1 = [CZItemArrow itemWithTitle:@"電話分享" icon:nil option:^{
        //通話完成會(huì)回到當(dāng)前應(yīng)用, 以前的時(shí)候不會(huì)回到當(dāng)前應(yīng)用
//        NSURL *url = [NSURL URLWithString:@"tel://54188"];
//        [[UIApplication sharedApplication] openURL:url];
        
        
        //打電話之前會(huì)有提示  回到當(dāng)前應(yīng)用   私有的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:^{
        
        //發(fā)完短信之后。會(huì)到短信界面
//        NSURL *url = [NSURL URLWithString:@"sms://54188"];
//        [[UIApplication sharedApplication] openURL:url];
        
        
        //判斷設(shè)備是否能發(fā)送信息
        if (![MFMessageComposeViewController canSendText]) {
            return;
        }
        
        MFMessageComposeViewController *vc = [MFMessageComposeViewController new];
        //收件人列表
        vc.recipients = @[@"10000",@"10086"];
        vc.body = @"推薦一個(gè)nb的游戲 http://www.nlcoder.com/test";
        vc.subject = @"biaoti";
        //設(shè)置代理
        vc.messageComposeDelegate = weakSelf;
        
        [weakSelf presentViewController:vc animated:YES completion:nil];
        
    }];
    
    CZItem *item3 = [CZItemArrow itemWithTitle:@"郵件分享" icon:nil option:^{
        
        //判斷是否能發(fā)送郵件
        if (![MFMailComposeViewController canSendMail]) {
            return;
        }
        
        MFMailComposeViewController *vc = [MFMailComposeViewController new];
        
        vc.mailComposeDelegate = weakSelf;
        //設(shè)置收件人
        [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下載

  1. 應(yīng)用推薦Demos下載地址:
    http://git.oschina.net/changyou/MyRecommendProductsDemo/repository/archive/master

  2. 第一次啟動(dòng)新特性Demo
    http://git.oschina.net/changyou/MyNewsFeatureDemo/repository/archive/master

  1. 仿網(wǎng)易彩票demo
    http://git.oschina.net/changyou/ImitationNeteaseLottery/repository/archive/master

如果你能夠在某個(gè)領(lǐng)域全身心投入一萬(wàn)個(gè)小時(shí),那么你一定是那個(gè)領(lǐng)域的專家。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容