oc
有酒有故事
黄沙百战穿金甲,不破楼兰终不还。
展开
-
蓝牙使用 iOS小结
做了一个单例h文件#import <Foundation/Foundation.h>#import <CoreBluetooth/CoreBluetooth.h>NS_ASSUME_NONNULL_BEGINtypedef void(^DidRefreshPeripherals)(void);typedef void(^CentralManagerDidUpda...原创 2020-03-06 10:17:10 · 336 阅读 · 0 评论 -
iOS 人脸识别拾遗一 坐标转换 截取
// 得到图片的尺寸 CIImage *faceImage = [CIImage imageWithCGImage:image.CGImage]; CGSize inputImageSize = [faceImage extent].size; //将image沿y轴对称 这个...原创 2020-03-06 10:10:04 · 401 阅读 · 0 评论 -
IOS三种多线程编程的技术
•NSThread: –优点:NSThread 比其他两个轻量级,使用简单 –缺点:需要自己管理线程的生命周期、线程同步、加锁、睡眠以及唤醒等。线程同步对数据的加锁会有一定的系统开销 1 [NSThread detachNewThreadSelector:@selector(dosth:) toTarget:self withObject:nil]; 2 NSTh原创 2016-09-14 15:31:44 · 366 阅读 · 0 评论 -
Unity3D和ios交互
using UnityEngine; using System.Collections; using System.Runtime.InteropServices;public class testFeil : MonoBehaviour {[DllImport("__Internal")]private static extern void c_ctest();// Use this for原创 2016-09-18 10:53:54 · 380 阅读 · 0 评论 -
数组按对象的属性排序
[ arr sortedArrayUsingComparator:^NSComparisonResult(id _Nonnull obj1, id _Nonnull obj2) { if ([obj1 floatValue] > [obj2 floatValue]) { return NSOrderedDescending; } i原创 2016-09-18 19:07:16 · 443 阅读 · 0 评论 -
iOS 一个程序 调起另外一个程序
A:NSURL *url = [NSURL URLWithString:@"ceshi://aaaaaaa"];[[UIApplication sharedApplication] openURL:url];B: targets–>info –>url type–>url schemes 实现代理:- (BOOL)application:(UIApplication *)applica原创 2016-09-14 10:49:44 · 411 阅读 · 0 评论 -
UIWebview和WKWebview的使用 js交互 本地加载 网络加载
#import "GameWebVC.h"#import "Header.h"#import "BaseHttpService.h"#import <WebKit/WebKit.h>@interface GameWebVC()<WKNavigationDelegate,UIWebViewDelegate>{ UIView *myWebView; UIImageView *l原创 2016-09-20 14:18:53 · 923 阅读 · 0 评论 -
转屏
设置工程为竖屏 从别处回来的时候起作用- (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeRight;}//一开始的方向 很重要-(UIInterfaceOrientation)preferredInterfaceOrientationForPresentati原创 2016-09-19 20:38:30 · 433 阅读 · 0 评论 -
enumerateObjectsUsingBlock
这是foundation里面的一个方法:- (void)enumerateObjectsUsingBlock:(void (^)(ObjectType obj, NSUInteger idx, BOOL *stop))block NS_AVAILABLE(10_6, 4_0);这个方法也是一种循环的方法与for,while实现的功能一样,但是既然苹果出了这个方法,那一定有它的与众不同的地方。NSAr转载 2016-09-23 10:40:18 · 482 阅读 · 0 评论 -
工程如何添加Alamofire
打开你的工程,把Alamofire-master文件放到工程文件夹中 点工程.xcodeproj右键add –>把Alamofire.xcodeproj这个工程添加到你的工程中注意选择copyifneed build Phases ->Target Dependencies ->Link Binary With Libraries 添加Alamofire.framework 即可原创 2016-10-09 15:27:12 · 1485 阅读 · 0 评论 -
ld: -weak_library and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together
ld: -weak_library and -bitcode_bundle (Xcode setting ENABLE_BITCODE=YES) cannot be used together clang: error: linker command failed with exit code 1 (use -v to see invocation) 解决 build setting ena原创 2016-10-09 15:31:31 · 1511 阅读 · 0 评论 -
Reason: image not found 错误解决方法
在Build Phases里把XXXXX.framework后边选项改成Optional就可以了原创 2016-10-09 15:33:40 · 5911 阅读 · 0 评论 -
iOS阿拉伯数字转化为中文数字
-(NSString*)transChinese{ NSString *str = self; NSArray *arabic_numerals = @[@”1”,@”2”,@”3”,@”4”,@”5”,@”6”,@”7”,@”8”,@”9”,@”0”]; NSArray *chinese_numerals = @[@”一”,@”二”,@”三”,@”四”,@”五”,@”六”,转载 2016-09-23 15:14:11 · 1653 阅读 · 0 评论 -
IPv4和IPv6支持
根据当前网络环境(IPv4/IPv6)返回,要访问的服务器的相应格式的ip地址 NSArray *serverDNSs = [IPAdapter getDNSsWithDormain:Host]; //Host为域名 if (!serverDNSs || serverDNSs.count <= 0) { NSLog(@"Could not get host原创 2016-10-09 17:38:41 · 858 阅读 · 0 评论 -
c 调用 oc
//1首先新建工程在加入一个ViewController 定义一个全局指针指向self#import "ViewController.h"//1定义ViewController *that = nil;//2在内部分别定义一个C函数和一个OC方法//定义一个C函数 void sendOC(){ [that sendMessage];}//定义一个OC方法 -(void)sendMes原创 2016-09-22 11:20:35 · 577 阅读 · 0 评论 -
json字符串 转NSDictionary
/*! * @brief 把格式化的JSON格式的字符串转换成字典 * @param jsonString JSON格式的字符串 * @return 返回字典 */- (NSDictionary *)dictionaryWithJsonString { NSString *jsonString =self; if (jsonString == nil) { return n原创 2016-09-22 13:47:26 · 1267 阅读 · 0 评论 -
iOS中书写代码规范35条小建议
1.精简代码, 返回最后一句的值,这个方法有一个优点,所有的变量都在代码块中,也就是只在代码块的区域中有效,这意味着可以减少对其他作用域的命名污染。但缺点是可读性比较差NSURL *url = ({ NSString *urlString = [NSString stringWithFormat:@"%@/%@", baseURLString, endpoint];[NSURL URLWithSt转载 2016-09-22 16:04:37 · 492 阅读 · 0 评论 -
apple开发者账号申请流程
apple开发者账号申请流程:原创 2016-09-26 15:43:18 · 368 阅读 · 0 评论 -
Cocoapods 安装使用方法
1.mac系统是有ruby环境的,不多说,想要查看当前源的话:$ gem sources -l (这是L)2.只要你以前没装过,你的源肯定是https://rubygems.org/,这一步需要删除这个源:$ gem sources –remove https://rubygems.org/3.删除后添加翻墙的ruby源,这里用淘宝的,以前的是http,现在是https:$ gem sources原创 2016-10-09 16:05:12 · 318 阅读 · 0 评论 -
利用SDWebImage下载image 使用
#import "SDWebImageManager.h" [[SDWebImageManager sharedManager] downloadImageWithURL:<#url#> options:0 progress:^(NSInteger receivedSize, NSInteger expectedSize) { } completed:^(UIImage *image,原创 2016-09-27 13:06:06 · 416 阅读 · 0 评论 -
c,c++,oc混编
将文件名.m->.mm即可 .cpp c/c++ .m oc原创 2016-09-14 14:03:31 · 347 阅读 · 0 评论 -
Object-C 中各数据类型转换 NSData NSMutableData NSString Byte UIImage 合并音频
1,NSData 与 NSString NSData –> NSString NSString *aString = [[NSString alloc] initWithData:adata encoding:NSUTF8StringEncoding]; NSString –> NSData NSString *aString = @”1234”; NSData *aD转载 2016-09-28 17:10:38 · 993 阅读 · 0 评论 -
iOS oc-NSString swift-String format
swift String(format: “%.2f”,1.22222) oc [NSString stringWithFormat:@”%.2f “,1.22222]; 保留两位 %@ oc的任何对象 %X 十六进制 A-F 0-9 %s c中的字符串 %c char %% 显示一个百分号 %g 无意义的小数位0 不显示 可以显示CGFloat原创 2016-09-28 20:04:17 · 3298 阅读 · 0 评论 -
IOS 嵌入 u3d 的步骤
1.处理sh的权限问题 终端 进入 sh的文件夹 chmod 755 scriptname.sh 2.处理oc语法 __weak try cacth Enable Objective-c Exceptions true 3处理bitcode Enable BitCode NO 4 MRC -ARC 处理 -fno-objc-arc 5 导入各种依赖包原创 2016-09-14 11:40:00 · 583 阅读 · 0 评论 -
友盟第三方登录分享集成参考
http://www.jianshu.com/p/7025087dc0ec转载 2016-10-26 13:37:57 · 318 阅读 · 0 评论 -
Cannot create __weak reference in file using manual refrence counting.
点击工程启动文件 - TARGETS -Build Settings - 在下方搜索框搜索weak - 在Apple LLVM 7.1 - Language - Objective C选项下边 - 把Weak Reference in Manual Retain Release选项改成YES即可原创 2016-10-04 14:09:40 · 324 阅读 · 0 评论 -
ios将两个字典合并
[param addEntriesFromDictionary:self.selectedDic]; 前者为目标字典 即将后者添加到param中.原创 2016-10-08 15:29:06 · 12531 阅读 · 0 评论 -
IOS检查版本更新
iOS的版本号, 一个叫做Version, 一个叫做Build. 获得Version , [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"];获得build号:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleV原创 2016-10-08 15:36:05 · 366 阅读 · 0 评论 -
IOS跳转去appStore评分
(void)gotoAppStore{NSString *str = [NSString stringWithFormat:@”itms-apps://ax.itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?type=Purple+Software&id=%@”, kAppId]; if ([[UIApplicat原创 2016-10-08 15:45:24 · 588 阅读 · 0 评论 -
iOS 如何加载gif
原理 利用webview CGRect frame = [UIScreen mainScreen].bounds; //frame.size = [UIImage imageNamed:@"yourname.gif"].size; NSData * gif = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathFor原创 2016-10-08 15:49:50 · 412 阅读 · 0 评论 -
IOS 截屏
UIGraphicsBeginImageContext(self.view.bounds.size); // 创建一个基于位图的图形上下文并指定大小为 [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];//renderInContext呈现接受者及其子范围到指定的上下文 UIImage *v原创 2016-10-08 15:55:44 · 342 阅读 · 0 评论 -
高仿微信和qq气泡聊天(整合精简版)
//定制单元cell#import "TableViewCell.h"@implementation TableViewCell-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{ self=[super initWithStyle:sty原创 2016-10-08 16:30:24 · 1019 阅读 · 0 评论 -
IOS类似于微信和qq的泡泡语音
// 未简化 不可复用 仅供参考//泡泡语音 - (UIView *)yuyinView:(NSInteger)logntime from:(BOOL)fromSelf withIndexRow:(NSInteger)indexRow withPosition:(int)position{//根据语音长度int yuyinwidth = 66+fromSelf;UIButton *button原创 2016-10-08 16:32:20 · 710 阅读 · 0 评论 -
iOS native push 小结
准备材料: “aps_development .cer” ,”push.p12”接下来我们打开终端将他们生成.pem文件1.把aps_development .cer文件生成.pcm文件,cd到push文件夹下openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem2.把push.p12文件生成为.pemopens原创 2016-12-16 14:26:30 · 447 阅读 · 0 评论 -
oc注释 写法
/** * @brief 添加设备 * @param _id 设备序列号 * @param user 用户id * @param name 设备名字 * @return 无返回. * @exception NSException 可能抛出的异常. * @see set_4 * @see someMethodByInt: * @warning 警告: . * @原创 2016-12-27 10:10:52 · 1554 阅读 · 0 评论 -
画线 ios
//float h=0;UIImageView *imageView1 = [[UIImageView alloc]initWithFrame:CGRectMake(0,0, SCREEN_WIDTH,h)];[self.view addSubview:imageView1];UIGraphicsBeginImageContext(imageView1.frame.size); //开始画线原创 2017-01-04 14:42:31 · 281 阅读 · 0 评论 -
iOS addChildViewController方法
苹果新的API增加了addChildViewController方法,并且希望我们在使用addSubview时,同时调用[self addChildViewController:child]方法将sub view对应的viewController也加到当前ViewController的管理中。 对于那些当前暂时不需要显示的subview,只通过addChildViewControlle原创 2017-02-08 10:59:48 · 1178 阅读 · 0 评论 -
ninePacth(.9.png) iOS 的实现
UIImage *image; CGFloat top = 10; // 顶端点(若拉伸 这个点会一直重复复制) CGFloat bottom = 10 ; // 底端点 CGFloat left = 10; // 左端点 CGFloat right = 10; // 右端点 UIEdgeInsets insets = UIEdgeInsetsMake(top, lef原创 2017-04-18 13:54:50 · 668 阅读 · 0 评论 -
share sdk WeChat unionid
uid就是opened,我们统一把openid写成了did,您可以获取整个第三方返回的用户信息,然后自己在里面获取到这个unionid的 NSDictionary * doc = user.rawData; NSLog(@”%@”,[doc objectForKey”unionid”]);原创 2017-04-14 11:01:50 · 747 阅读 · 0 评论 -
url传中文乱码问题解决办法
编码要一致byte[] res; new String(res,"utf-8"); 1。base64编码里面有一个 “+” 号,在urlecode编码中 “+” 会被解码成空格 2。http头里面可能会用base64编码来传输一些信息,因为这些信息不会被web服务器默认做url解码的。 3。每76个字符都会添加一个换行”\n”,这个换行符会丢失。所以在传输和解密时要做如下处理:1.去掉\n2原创 2017-04-20 12:37:07 · 455 阅读 · 0 评论