ios开发

1

http://blog.csdn.net/nogodoss/article/details/39156125

_observer = [[NSNotificationCenter defaultCenter] addObserverForName

获得的notification需要用下面的方法清除

if(_observer){ 

     [[NSNotificationCenter defaultCenter] removeObserver:_observer];

}

2

http://www.it165.net/pro/html/201501/31966.html

  • GCDAsyncUdpSocket本身提供的:

    GCDAsyncUdpSendPacket *packet = [[GCDAsyncUdpSendPacket alloc] initWithData:data timeout:timeout tag:tag]; 下面添加这行代码就可以根据输入的参数来超时了

    [self setupSendTimerWithTimeout:timeout];

    然后就会调用:

     

    - (void)udpSocket:(GCDAsyncUdpSocket *)sock didNotSendDataWithTag:(long)tag dueToError:(NSError *)error 委托方法了

    还有本人为发送数据可以建立一个类,通过

    [self performSelector:@selector(requestTimeout) withObject:nil afterDelay:PACKET_TIMEOUT];

    [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(requestTimeout) object:nil];

    或者定时器来也可以实现一个超时机制

  • - (void)sendData:(NSData *)data toHost:(NSString *)host port:(uint16_t)port withTimeout:(NSTimeInterval)timeout tag:(long)tag 方法写入参数timeout默认是不会根据填写的参数来超时的,需要在这个方法的

3  解决像素空白

http://doc.okbase.net/mrliuzhe/archive/119026.html

ios7中,UITableViewCell左侧会有默认15像素的空白。设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉。

ios8中,setSeparatorInset:UIEdgeInsetsZero 的设置已经不起作用了。

下面是解决办法,首先在viewDidLoad方法加入以下代码:

if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)])

{

     [self.tableView setSeparatorInset:UIEdgeInsetsZero];

}

if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)])

 {

     [self.tableView setLayoutMargins:UIEdgeInsetsZero];

}

然后在UITableView的代理方法中加入以下代码

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

{

    if ([cell respondsToSelector:@selector(setSeparatorInset:)])

       {

          [cell setSeparatorInset:UIEdgeInsetsZero];

       }

    if ([cell respondsToSelector:@selector(setLayoutMargins:)])

       {

         [cell setLayoutMargins:UIEdgeInsetsZero];

       }

}

4 将xcode中的日志输出保存到手机目录中

http://blog.163.com/cz_jdton/blog/static/927325042014112103137623/

// log输入到文件

    freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], "a+", stdout);

    freopen([logFilePath cStringUsingEncoding:NSASCIIStringEncoding], "a+", stderr);


5最近直接在viewcontroller最上面放一个scrollview,会发现scrollview会莫名的向下移动了一段距离,

修改下viewcontroller中的adjust scroll view insets为false即可

http://www.tuicool.com/articles/BVBZVf


6在用pod的时候遇到报错,

- `ProtocolBuffers-Swift (= 1.6.2)` required by `Podfile`

- `ProtocolBuffers-Swift (= 1.6.2)` required by `Podfile.lock`


是pod的时候ios的版本低于所用的库配置的最低版本

老外的这个解决方案不错

cd  ~/.cocoapods/repos/master/Specs

然后修改对应的ios版本号

http://stackoverflow.com/questions/28592045/cocoapods-afnetworking-required-by-podfile


my pod version is 0.38.2.

the solution is this:add platform :ios,'7.0' at the beginning of the Podfile.

the 7.0 also could be 6.0 or 5.0 or 8.0,that depends on the items in your Podfile.You can cd into the ~/.cocoapods/repos/master/Specs folder,and open the .podspec file you need.In these files,they may declared the version of ios sdk.Replace the 7.0 with the maximum version number.try update or install again.That could be your help.



7在ios7及以下用来判断ios的版本


if  UIDevice.currentDevice().systemVersion.compare("8.0", options: NSStringCompareOptions.NumericSearch, range: nil, locale: nil) != NSComparisonResult.OrderedAscending  为ios8

  • 当最低目标适配为iOS 8以上时,使用NSProcessInfo operatingSystemVersion 或isOperatingSystemAtLeastVersion。
详情:http://idlelife.org/archives/716



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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值