iOS开发中常用但经常忘记的技巧

来源:互联网 发布:五五开这个人 知乎 编辑:程序博客网 时间:2024/05/16 01:03

iOS开发中常用但经常忘记的技巧

1、 隐藏tableViewCell的分割线:

tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
2、实现右侧的小灰色箭头 只要将cell的accessoryType属性设置为

cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

//关闭tableView顶部的cell冒出来的白色空隙self.automaticallyAdjustsScrollViewInsets = NO
//关闭tableView选中的动画[tableView deselectRowAtIndexPath:indexPath animated:NO];
 开启手势返回 self.navigationController.interactivePopGestureRecognizer.delegate = (id)self;

其他格式:像对勾、删除什么类似,更改一下属性值即可

3、 用UiButton制作圆形头像时,去除头像多余的部分
button.clipsToBounds = YES;
4、毛玻璃效果(ios8.0以后的版本)
UIVisualEffectView *visualEffectView = [[UIVisualEffectView alloc] initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]];    visualEffectView.frame = CGRectMake(0, 0, 320*[FlexibleFrame ratio], 180*[FlexibleFrame ratio]);    visualEffectView.alpha = 1.0;
5、关闭textField、textView 相关
//是否自动纠错功能  text.autocorrectionType = UITextAutocorrectionTypeNo;typedef enum {    UITextAutocorrectionTypeDefault, 默认    UITextAutocorrectionTypeNo,  不自动纠错    UITextAutocorrectionTypeYes, 自动纠错} UITextAutocorrectionType;


6、每输入一个字符就变成点 用语密码输入
 text.secureTextEntry = YES;
7、pod更新慢


CocoaPods来添加第三方类库,无论是执行pod install还是pod update都卡在了Analyzing dependencies不动 原因在于当执行以上两个命令的时候会升级CocoaPods的spec仓库,加一个参数可以省略这一步,然后速度就会提升不少。加参数的命令如下:

pod install --verbose --no-repo-updatepod update --verbose --no-repo-update


8、查看代码行数

find . -name ".m" -or -name ".h" -or -name ".xib" -or -name ".c" |xargs wc -l  1

二、Mac系统技巧

显示Mac隐藏文件的命令: ```

defaults write com.apple.finder AppleShowAllFiles -bool true ```

隐藏Mac隐藏文件的命令:

defaults write com.apple.finder AppleShowAllFiles -bool false

或者

显示Mac隐藏文件的命令:

defaults write com.apple.finder AppleShowAllFiles  YES

隐藏Mac隐藏文件的命令:

defaults write com.apple.finder AppleShowAllFiles  NO


输完单击Enter键,退出终端,重新启动Finder就可以了

重启Finder:鼠标单击窗口左上角的苹果标志-->强制退出-->Finder-->重新启动

三、解决Xcode升级插件失效问题

  1. 编写脚本

随便打开一个编辑器,Xcode可以,Sublime也可以,创建一个名为script.sh的文件,打开文件,并复制粘贴以下代码:

 #!/bin/bash #获取当前版本Xcode的   DVTPlugInCompatibilityUUIDUUID=$(defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID)echo Xcode DVTPlugInCompatibilityUUID is $UUID #遍历每一个Xcode插件,将UUID写入插件的兼容列表中for MyPlugin in ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins/*dodefaults write "$MyPlugin"/Contents/Info DVTPlugInCompatibilityUUIDs -array-add $UUIDecho write DVTPlugInCompatibilityUUID to $MyPlugin succeed!done

1、给权限

在终端中输入以下命令(755后面是脚本的路径): chmod 755 /Users/tangjr/Desktop/script.sh 

2、 关闭Xcode

3、运行脚本

直接将脚本拖到终端中就行。 

4、 结束

重新打开Xcode就行


转自:http://blog.cocoachina.com/article/14261

0 0
原创粉丝点击