Skip to content

Instantly share code, notes, and snippets.

@lvyile
lvyile / gist:8552322
Last active January 4, 2016 01:59
UIWebView 禁止长按和选择 (Client/Server,2套方案)
#pragma mark - Client
#pragma mark UIWebViewDelegate
- (void)webViewDidFinishLoad:(UIWebView *)webView {
// Disable user selection
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
// Disable callout
[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
}
@lvyile
lvyile / 新浪微博字数统计函数
Created April 9, 2011 17:52
新浪微博对每条信息有 140 字的上限限制,所以 CocoaChia 会员“keefo”分享了他的新浪微博字数统计函数,做微博客户端应用的开发者可以以此加入字数统计功能以方便用户
- (int)sinaCountWord:(NSString*)s{
int i,n=[s length],l=0,a=0,b=0;
unichar c;
for(i=0;i<n;i++){
c=[s characterAtIndex:i];
if(isblank(c)){
b++;
}else if(isascii(c)){
a++;
}else{
@lvyile
lvyile / gist:823601
Created February 12, 2011 08:13
Cast
- (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)aResponse{
NSHTTPURLResponse* aHttpResponse = (NSHTTPURLResponse*)aResponse;
NSLog(@"aResponse[%@]", aHttpResponse.allHeaderFields);
}
#define DocumentsPath(name) \
[[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] stringByAppendingPathComponent:name]