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。