nsstring

Play embedded video in UIWebView with HTML5

匿名 (未验证) 提交于 2019-12-03 00:48:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I'm actually trying to play a local video into an UIWebView, with HTLM5. What I do actually is this : NSString * embedHTML = [ NSString stringWithFormat :@ "\ \ */ /*--> */ \ \ < src=\"%@\" \ \ " , [[ NSBundle mainBundle ] pathForResource :@ "ash(1).mov" ofType : nil ]]; [ webView setOpaque : NO ]; NSString * html = [ NSString stringWithFormat : embedHTML , webView . frame . size . width , webView . frame . size . height ]; [ webView loadHTMLString : html baseURL : nil ]; I have on my storyboard an UIWebView named webView with weak

NSString replace repeated newlines with single newline

痞子三分冷 提交于 2019-12-03 00:45:56
I have an NSString which can have multiple \n in between the string. I need to replace the multiple occurrence of \n's with a single \n. I tried this code: newString = [string stringByReplacingOccurrencesOfString:@"\n\n" withString:@"\n"]; But this does not give the desired result if a series of "\n\n\n\n\n\n" is encountered in the string. In this case, they will be replaced with "\n\n\n". What should I do so that all more than one "\n"s be replaced with single "\n"? Thanks to all! Update: Adding a screenshot for UITextView to which the filtered string is set as text. The new lines seem to be

Error Domain=NSCocoaErrorDomain Code=512 \&quot;The operation couldn’t be completed.The operation couldn’t be completed. Is a directory

匿名 (未验证) 提交于 2019-12-03 00:44:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want use writeToFile to store a pic image to the documents, but find the error below, how to solve it ? Error Domain=NSCocoaErrorDomain Code=512 "The operation couldn’t be completed. (Cocoa error 512.)" {NSFilePath=/Users/alexqdh/Library/Application Support/iPhone Simulator/6.0/Applications/xxx/Documents/girl.png, NSUnderlyingError=0x753e630 "The operation couldn’t be completed. Is a directory"} -(NSString*)getImagePath:(NSString *)name { NSArray *path =NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

支付宝支付总结

匿名 (未验证) 提交于 2019-12-03 00:40:02
现在不少app内都集成了支付宝功能 使用支付宝进行一个完整的支付功能,大致有以下步骤: 1>先与支付宝签约,获得商户ID(partner)和账号ID(seller) (这个主要是公司的负责) 2>下载相应的公钥私钥文件(加密签名用) 3>下载支付宝SDK(登录网站: http://club.alipay.com/ ) 里面提供了非常详细的文档、如何签约、如何获得公钥私钥、如何调用支付接口。 4>生成订单信息 5>调用支付宝客户端,由支付宝客户端跟支付宝安全服务器打交道 6>支付完毕后返回支付结果给商户客户端和服务器 SDK里有集成支付宝功能的一个Demo> 集成支付功能的具体操作方式,可以参考Demo 当第一次打开Demo时,可能会出现以下问题: 错误原因很简单,就是项目的部署版本设置太低了,从3.0改为4.3即可 ?6?1要想集成支付功能,依赖以下文件夹的库文件(把这3个添加到你的客户端中) 调用支付接口可以参考AlixPayDemoViewController的下面方法 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 如何创建订单 ( 订单根据自己公司看是什么样的) 如何签名 如何调用支付接口 都在这个方法里面了 view source

swift - YYCache ֮ YYDiskCache

匿名 (未验证) 提交于 2019-12-03 00:38:01
YYDiskCache缓存是通过file文件,splits进行数据存储与读取操作,直接放代码 初始化方法: - ( nullable instancetype )initWithPath:( NSString *)path; - ( nullable instancetype )initWithPath:( NSString *)path NSUInteger )threshold 我们看两个方法的实现: - ( instancetype )initWithPath:( NSString *)path { initWithPath :path inlineThreshold : 1024 * 20 ]; // 20KB } - ( instancetype )initWithPath:( NSString *)path NSUInteger )threshold { init ]; YYDiskCache *globalCache = _YYDiskCacheGetGlobal (path); YYKVStorageType type; 0 ) { YYKVStorageTypeFile ; NSUIntegerMax ) { YYKVStorageTypeSQLite ; YYKVStorageTypeMixed ; YYKVStorage *kv = [[

iOS 通过URL Scheme跳转到常用的App

匿名 (未验证) 提交于 2019-12-03 00:37:01
微博开放的接口是最多的(在网上找了个遍) 打开微博: sinaweibo:// 打开微博个人主页: sinaweibo://userinfo?uid=xxxxxxxxx 打开具体某一条微博: sinaweibo://detail?mblogid=4236343749739805 打开微博头条文章: sinaweibo://article?object_id=2309404247873553304181 评论指定的微博: sinaweibo://comment?srcid=4236343749739805 主页我的消息流: sinaweibo://gotohome 打开我的界面: sinaweibo://myprofile 分享到微博: sinaweibo://sendweibo?content=分享每日心情 需要对汉字进行转码 -(NSString *)url:(NSString *)transcodingUrl{ NSString *encodedString = [transcodingUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]; return encodedString; } 链接到指定搜索流:汉字处理同上

iOS 时间和时间戳使用

匿名 (未验证) 提交于 2019-12-03 00:27:02
一、获取当前时间 //获取当前时间 - ( NSString *)currentDateStr{ NSDate *currentDate = [ NSDate date]; //获取当前时间,日期 NSDateFormatter *dateFormatter = [[ NSDateFormatter alloc] init]; // 创建一个时间格式化对象 [dateFormatter setDateFormat: @"YYYY/MM/dd hh:mm:ss SS " ]; //设定时间格式,这里可以设置成自己需要的格式 NSString *dateString = [dateFormatter stringFromDate:currentDate]; //将时间转化成字符串 return dateString; } 二、获取当前时间戳 //获取当前时间戳 - ( NSString *)currentTimeStr{ NSDate * date = [ NSDate dateWithTimeIntervalSinceNow: 0 ]; //获取当前时间0秒后的时间 NSTimeInterval time=[date timeIntervalSince1970]* 1000 ; // *1000 是精确到毫秒,不乘就是精确到秒 NSString *timeString = [

SQLite-OC

匿名 (未验证) 提交于 2019-12-03 00:22:01
-( void )openSqlite:( NSString *)sqliteName{ if (!sqliteName || sqliteName .length <= 0 ) { NSAssert(sqliteName, @ "sqliteName is null" ); } if (!db) { NSString *basePath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES ) firstObject]; NSString *path = [basePath stringByAppendingPathComponent:sqliteName]; NSLog (@ "sqlite 存放位置:%@" ,path); //打开数据库,若存在则打开;反之不存在就创建一个数据库再打开 int result = sqlite3_open([path UTF8String], &db); if (result == SQLITE_OK) { NSLog (@ "数据库打开成功" ); return ; } else { NSLog (@ "数据库打开失败" ); } } } 创建表 & 删除表(表结构) - (BOOL)createTable{ NSString

WKWebView 在 tableview 上的展示

匿名 (未验证) 提交于 2019-12-03 00:22:01
创建 WKWebView _webView = [[WKWebView alloc]initWithFrame:self .view .bounds ] ; _webHeight = _webView .height ; _webView .backgroundColor = [UIColor whiteColor] ; _webView .UIDelegate = self ; _webView .navigationDelegate = self ; _webView .scrollView .bounces = NO ; _webView .scrollView .scrollEnabled = NO ; _webView .scrollView .showsHorizontalScrollIndicator = NO ; _webView .scrollView .delegate = self ; WKWebView加载 html 数据: NSString *result = [ NSString stringWithFormat:@ "<img style='display: block; max-width: %.0f'" ,kScreenWidth]; id courseData = self .object ; NSAttributedString

objc_setAssociatedObject 的应用

匿名 (未验证) 提交于 2019-12-03 00:22:01
绑定值 绑定 objc_ set AssociatedObject(btn, "firstObject" , firsrString, OBJC_ASSOCIATION_RETAIN_NONATOMIC); 获取 objc_getAssociatedObject(sender, "firstObject" ) ; 2.为现有对象添加新属性 @property(nonatomic,copy)NSString *title; - ( NSString *)title{ return objc_getAssociatedObject( self ,&titleKey); } - ( void )setTitle:( NSString *)title{ objc_setAssociatedObject( self ,&titleKey,title,OBJC_ASSOCIATION_COPY); } 1.id objc_getAssociatedObject(id object, void *key) 2.void objc_setAssociatedObject(id object, void *key, id value, objc_AssociationPolicy policy) 该函数中第一位参数表示目标对象, 第二个参数,key。因为一个对象可以关联多个新的对像