PPMT---ios开发技巧<一>

作者: PPAbner | 来源:发表于2015-11-14 22:39 被阅读293次

    算是自己平时用的多的,在此收集起来,分享给大家,有些知识也是看了别人的分享才知道的,所以共享之!
    由于篇幅问题,每一篇分享10个技巧

    【1】tableView相关
    //去掉所有分割线
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    //去掉多余的分割线
        [self.tableView setTableFooterView:[[UIView alloc] initWithFrame:CGRectZero]];
    //cell不显示选中状态
         cell.selectionStyle = UITableViewCellSelectionStyleNone;
    //拖动tableView时收起键盘
         tableView.keyboardDismissMode = UIScrollViewKeyboardDismissModeOnDrag;
    
    【2】利用Runtime实现跳转到指定的VC
    //利用Runtime实现跳转到指定的VC
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSString *demoClassString = [NSString stringWithFormat:@"DemoVC%ld", indexPath.row];    
        [self.navigationController pushViewController:[NSClassFromString(demoClassString) new] animated:YES];
    }
    
    【3】修改iOS9后https的需求(还有bitcode要设置为NO)
    //修改iOS9后https的需求(还有bitcode要设置为NO)
     1. 在Info.plist中添加NSAppTransportSecurity类型Dictionary。
     2. 在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
    
    【4】XCode快速隐藏的快捷键
    //XCode快速隐藏的快捷键
    1.shift + option + command +左箭头 //隐藏所有的方法
    2.shift + option + command +左箭头 //取消隐藏的所有方法
    
    3.option + command +左箭头 //隐藏光标所在行的方法
    4.option + command +左箭头 //取消隐藏光标所在行的方法
    
    【5】日版Mac反斜杠和顿号的打法
    //日版Mac反斜杠的打法:【英文输入法状态下】option+¥
    //日版Mac顿号的打法:   【中文输入法状态下】option+¥
    
    【6】bt不能再点击
    //bt不能再点击
    bePlnnerBT.enabled = NO;
    
    【7】判断一个字符串中是不是包含另一个字符串
    //我的关注url
    NSString *url = [NSString stringWithFormat:@"api/%@/%@/attention", typeString, ID];
    //在APIManager.m中 判断下面代码后做特殊处理
    [url rangeOfString:@"attention"].location ==NSNotFound
    

    【8】局部刷新UITableView刷新局部cell

    //8.1 刷新局部cell【局部的刷新了第一个section的第一个cell】
    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:0 inSection:0]; 
    [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationFade];
    //8.2 刷新局部section 【单独刷新第一个section】
    NSIndexSet *indexSet = [[NSIndexSet alloc] initWithIndex:0];
    [self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationFade];
    
    
    【9】只有小数点和数字的键盘
    //只有小数点和数字的键盘
    cell.detailTf.keyboardType = UIKeyboardTypeDecimalPad;
    
    【10】把拍照的照片保存的系统相册
    #pragma mark --- UIImagePickerControllerDelegate
    -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
        NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType];
        UIImage *originalImage;
        if (CFStringCompare((CFStringRef) mediaType,kUTTypeImage, 0)== kCFCompareEqualTo) {
            originalImage = (UIImage *) [info objectForKey:UIImagePickerControllerOriginalImage];
            //把拍照的照片保存的系统相册
            UIImageWriteToSavedPhotosAlbum(originalImage, nil, nil, nil);
    
        }
    }
    

    附录:

    附_1 刷新动画还有其他几个动画可以使用

    typedef NS_ENUM(NSInteger, UITableViewRowAnimation) { 
    UITableViewRowAnimationFade, //淡入淡出 
    UITableViewRowAnimationRight, //从右滑入  
    UITableViewRowAnimationLeft, //从左滑入 
    UITableViewRowAnimationTop, //从上滑入 
    UITableViewRowAnimationBottom, //从下滑入 
    UITableViewRowAnimationNone, // available in iOS 3.0 
    UITableViewRowAnimationMiddle, // available in iOS 3.2. attempts to keep cell centered in the space it will/did occupy UITableViewRowAnimationAutomatic = 100 // available in iOS 5.0. chooses an appropriate animation style for you
    };
    

    相关文章

      网友评论

      本文标题:PPMT---ios开发技巧<一>

      本文链接:https://www.haomeiwen.com/subject/jfdkhttx.html