iOS中常用小知识点

CocoaPods安装及使用

1.查看下当前ruby版本 ruby -v
2.更新ruby
   终端输入如下命令(把Ruby镜像指向taobao,避免被墙,你懂得)
   gem sources --remove https://rubygems.org/ 
   gem sources -a https://ruby.taobao.org/ 
   gem sources -l  (用来检查使用替换镜像位置成功)
3. sudo gem install cocoapods
4. 终端中,cd到项目总目录(注意:包含PodTest文件夹、PodTest.xcodeproj、PodTestTest的那个总目录)     即项目文件夹
5. 建立Podfile(配置文件) 
   接着上一步,终端输入 vim Podfile
   编辑   platform :ios, '7.0' 
             pod 'MBProgressHUD', '~> 0.8'
6.pod install
pod update更新类库
pod search可以搜索网络上的类库

原因是上面命令会升级CocoaPods的spec仓库,以下命令则是忽略

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


在控制台里打印controller的层级

在控制台里使用po [UIViewController _printHierarchy]命令即可打印出controller的层级


在lldb使用po可以打印frame

打开终端执行以下命令即可

1. touch ~/.lldbinit

2. echo display @import UIKit >> ~/.lldbinit

3. echo target stop-hook add -o \"target stop-hook disable\" >> ~/.lldbinit


Tableview多余的cell不显示分割线

UITableView *tableView=[[UITableViewalloc]init];

tableView.tableFooterView=[[UIViewalloc]init];


打印view的所有子控件 
NSLog(@"%@", [self.view performSelector:@selector(recursiveDescription)]);


修改UISearchBar背景色为透明 
 self.searchController.searchBar.backgroundColor = [UIColor clearColor];
 [self.searchController.searchBar.subviews[0].subviews[0] removeFromSuperview];


修改UITableView索引条背景色 
不滑时背景色
 self.tableView.sectionIndexBackgroundColor = [UIColor clearColor];
滑动时背景色
 self.tableView.sectionIndexTrackingBackgroundColor = [UIColor colorWithWhite:0.5 alpha:0.5];


修改UITableView右侧索引文字颜色
for (UIView *view in self.tableView.subviews) {
        if ([view isKindOfClass:NSClassFromString(@"UITableViewIndex")]) {
            [view performSelector:@selector(setIndexColor:) withObject:[UIColor blackColor]];
        }
    }

修改UITableView的headerView显示string时设置headerView背景色

- (void)tableView:(UITableView*)tableView willDisplayHeaderView:(UIView*)view forSection:(NSInteger)section

{

    UITableViewHeaderFooterView* v = (UITableViewHeaderFooterView*)view;

    v.textLabel.textColor =RGB(TEXT_COLOR_FIVE,1.0);

    v.textLabel.font = [UIFontsystemFontOfSize:13];

    v.contentView.backgroundColor =RGB(BG_COLOR_TWO,1.0);

}


打开设置中本应用程序界面
   [[UIApplication sharedApplication]openURL:[NSURL  URLWithString:UIApplicationOpenSettingsURLString]];



解决view中添加tableview view添加单击手势 cell didSelect不调用冲突

#pragma mark -UIGestureRecognizerDelegate

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

{

    if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"]) {

        return NO;

    }

    return YES;

}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值