iOS学习笔记

2015.7.22

UINavigationBar添加按钮:

通过UIBarButtonItem的initWithCustomView创建一个按钮,并通过UIViewController的.navigationItem.rightBarButtonItem设置按钮

(target是UIViewController实例)

UIView *rightBarView = [targetgetRightBarView];

    if (rightBarView) {

        UIBarButtonItem *rightItem = [[UIBarButtonItemalloc]initWithCustomView:rightBarView];

        target.navigationItem.rightBarButtonItem = rightItem;

    }


2015.7.23

iOS 启动页面

直接把欢迎图片命名为 Default.png 就可以了。

http://blog.sina.com.cn/s/blog_74461f32010180it.html

代码注释

/**
  *  顶部公告btn
  */

会有注释提示。类似的:

/**顶部公告btn */

/**< 发送按钮 */

2015.7.27

sourcetree 链接git oschina。

1.   ssh-keygen -t rsa -C "heytrue@qq.com"

2.   将.ssh/id_rsa.pub添加到git oschina公钥

3.   ssh-add ~/.ssh

4.   ssh -T git@git.oschina.net

5.   git config --global user.name "zhuqiaochu"

6.   git config --global user.email "heytrue@qq.com"

使用sourcetree克隆到本地要用项目的ssh地址git@git.oschina.net:truestudio/XcodeTest.git而不是https地址,否则出错

2015.8.5

iOS无法获取sim卡信息,iOS5以后不能获取设备miei号。

2015.8.6

终于把ice objc 跑通了,记录一下。objc的版本是叫ice touch。

https://doc.zeroc.com/display/Ice36/Using+the+Ice+Touch+Binary+Distribution

按照官方文档,首先

Installing the Ice Touch binary distribution

使用 Homebrew, 在命令行输入:

brew tap zeroc-ice/tap
brew install icetouch36

然后

Setting up your OS X environment to use Ice Touch


https://github.com/zeroc-ice/ice-builder-xcode 下载Ice Builder for Xcode,直接用xcode打开运行就可以。

这样环境就建好了。

在需要ice的工程属性里Additional SDKs里加入

Objective-C SDK

/usr/local/IceTouch/ObjC/$(PLATFORM_NAME).sdk

C++ SDK

/usr/local/IceTouch/Cpp/$(PLATFORM_NAME).sdk

用objc就加入第一行的即可。

(修改,应为) /usr/local/lib/IceTouch/ObjC/$(PLATFORM_NAME).sdk

对于ice工程,只要把.ice文件加入到工程,编译时就会自动生成.h和.m文件。对于生成的.h和.m文件不必看其源码。

服务器端,需要在工程里创建新类,继承自生成的.h文件,并实现方法。import新类。

客户端不必继承,import .ice生成的.h文件



关于dispatch_async

http://blog.csdn.net/totogo2010/article/details/8016129

  1. dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{  
  2.     // 耗时的操作  
  3.     dispatch_async(dispatch_get_main_queue(), ^{  
  4.         // 更新界面  
  5.     });  
  6. });  

2015.8.12

关于UIButton按下状态。

forState:UIControlStateSelected |UIControlStateHighlighted



2015.8.14

UITableView关于reloadDate crash

(建议看原帖)

http://www.cocoachina.com/bbs/read.php?tid=81462

问题的本质:在tableView的dataSource被改变 和 tableView的reloadData被调用之间有个时间差,而正是在这个期间,tableView的delegate方法被调用,如果新的dataSource的count小于原来的dataSource count,crash就很有可能发生了。

正确的方法:

dispatch_async(dispatch_get_main_queue(), ^{
        self.dataSourceArray= a new Array.
        [self.tableView reloadData];
});

===========

MJRefresh乃UITableview下拉刷新上拉加载的神器


2015.8.17

UILabel行距

    NSMutableAttributedString * attributedString1 = [[NSMutableAttributedStringalloc]initWithString:STR_SIGN_NOT];

    NSMutableParagraphStyle * paragraphStyle1 = [[NSMutableParagraphStylealloc]init];

    [paragraphStyle1 setLineSpacing:8];

    [attributedString1 addAttribute:NSParagraphStyleAttributeNamevalue:paragraphStyle1range:NSMakeRange(0, [STR_SIGN_NOTlength])];

    [_bindDetailLabelsetAttributedText:attributedString1];


2015.8.26

iOS 5.1(反正是5.几)以后无法通过openurl打开某个设置页面,iOS8.4可以通过

NSURL *settingsURL = [NSURLURLWithString:UIApplicationOpenSettingsURLString];

        [[UIApplicationsharedApplication]openURL:settingsURL];

进入设置根目录



iOS无法修改launchImage或者launchScreen.xib,也就是无法动态的修改启动页面,


http://stackoverflow.com/questions/16912754/change-the-launch-image-of-an-app-on-every-launch

The simple answer is NO you are not allowed to do this. This is because the image that you would have to modify is Default.png which is the launch image name which is located in the main bundle of the project, and it is not allowed to edit/amend/modify files in the main bundle of an iOS project.

This is because the contents of the main bundle are cryptographically (Think that's how it's spelt) signed as part of the Apple App store submission. So in modifying the contents within the main bundle could cause the application to stop running.


http://stackoverflow.com/questions/7015532/dynamically-change-launch-image-in-ios

The default image for an iphone app must be a fixed image file in your bundle. You cannot change it dynamically.

However, you can have a dynamic image that appears when the app loads after the launch image. You can set that up with animations or simply to select a random image each time.


关于设置本地保存目录

  • Put app-created support files in the Library/Application support/ directory. In general, this directory includes files that the app uses to run but that should remainhidden from the user. This directory can also include data files,configuration files, templates and modified versions of resources loaded from the app bundle.


2015.08.27

  • Default.png (iPhone)
  • Default@2x.png (iPhone Retina 3.5 inch)
  • Default@3x.png (iPhone 6 Plus landscape)
  • Default-568h@2x.png (iPhone Retina 4 inch)
  • Default-667h@2x.png (iPhone 6 portrait)
  • Default-Portrait.png (iPad in portrait orientation)
  • Default-Portrait@2x.png (iPad Retina in portrait orientation)
  • Default-Portrait@3x.png (iPhone 6 Plus portrait)
  • Default-Landscape.png (iPad in landscape orientation)
  • Default-Landscape@2x.png (iPad Retina in landscape orientation)

   320x480(2x) ->   640x960: Default@2x~iphone.png
   320x568(2x) ->  640x1136: Default-568h@2x~iphone.png
   375x667(2x) ->  750x1334: Default-667h@2x~iphone.png
   414x736(3x) -> 1242x2208: Default-736h@3x~iphone.png
  768x1024(1x) ->  768x1024: Default-Portrait~ipad.png
  1024x768(1x) ->  1024x768: Default-Landscape~ipad.png
  768x1024(2x) -> 1536x2048: Default-Portrait@2x~ipad.png
  1024x768(2x) -> 2048x1536: Default-Landscape@2x~ipad.png

2015.08.28

resizableImageWithCapInsets 使图片成为类似android的9patch

http://my.oschina.net/u/557242/blog/185535

上面所提及的capinsets的单位是point而非pixel,在高清的情况下1point等于2pixel。(@2x)


2015.09.10

static 变量 可能会被编译器优化,函数调用参数用到static有可能尚未被赋值


2015.09.21

c++ 指针成员变量在new之前似乎应该赋值为NULL,不然new会出错..


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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值