Skip to content

Instantly share code, notes, and snippets.

// 文档 https://www.dropbox.com/developers/reference/api#metadata
// api中有个earlier date http://forums.dropbox.com/topic.php?id=51560
// 例子 http://www.nanaimostudio.com/blog/2011/1/20/how-to-synchronize-your-app-data-using-dropbox-api.html
- (void)updateButtons {
NSString* title = [[DBSession sharedSession] isLinked] ? @"Unlink Dropbox" : @"Link Dropbox";
[linkDropboxBtn setTitle:title forState:UIControlStateDisabled];
linkDropboxBtn.enabled = [[DBSession sharedSession] isLinked];
}
@xxd
xxd / fileControl.h
Created May 13, 2012 13:51
Read,Write,List files in sandbox
// 把 图片 写入 沙盒
-(void)photoFile {
//此处首先指定了图片存取路径(默认写到应用程序沙盒 中)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES);
//并给文件起个文件名
NSString *uniquePath=[[paths objectAtIndex:0] stringByAppendingPathComponent:@"pin"];
BOOL blHave=[[NSFileManager defaultManager] fileExistsAtPath:uniquePath];
if (blHave) {
@xxd
xxd / example.m
Created May 13, 2012 04:19 — forked from henrik/example.m
Locating the keyboard (UIKeyboard) on iOS 4 and iOS 5
-------------for iOS 5---------------
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidChangeFrameNotification object:nil];
}
//dont forget to [[NSNotificationCenter defaultCenter] removeObserver:self]; on viewDidUnload
- (void)viewDidUnload
{
@xxd
xxd / gist:2658658
Created May 11, 2012 09:40 — forked from odrobnik/gist:2593533
Control caret by dragging on Keyboard
- (void)keyboardWillShow:(NSNotification *)notification
{
NSArray *appWindows = [[UIApplication sharedApplication] windows];
UIWindow *keyboardWindow = [appWindows lastObject];
UIView *keyboardView = [keyboardWindow.subviews objectAtIndex:0];
keyboardView = [keyboardView.subviews objectAtIndex:0];
keyboardView = [keyboardView.subviews objectAtIndex:0];
keyboardView = [keyboardView.subviews objectAtIndex:0];
@xxd
xxd / gist:2625814
Created May 7, 2012 03:58
[T-SQL]Search text in Stored procedure in SQLServer
select b.name
from db_name.dbo.syscomments a,db_name.dbo.sysobjects b
where a.id=b.id and b.xtype='p' and a.text like '%字符串%';
@xxd
xxd / gist:2582744
Created May 3, 2012 03:10
判断ios的版本
//判断ios的版本
[[[UIDevice currentDevice] systemVersion] floatValue];
@xxd
xxd / Ror_init.el
Created May 2, 2012 14:07 — forked from mig/init.el
[Lisp]Simple Emacs 24 configuration for Rails development
;; Basic Settting
(push "/usr/local/bin" exec-path)
(setq make-backup-files nil)
(setq auto-save-default nil)
(setq-default tab-width 2)
(setq-default indent-tabs-mode nil)
(setq inhibit-startup-message t)
(fset 'yes-or-no-p 'y-or-n-p)
(delete-selection-mode t)
(scroll-bar-mode -1)
@xxd
xxd / gist:2516837
Created April 28, 2012 07:24
简单贴图
//贴背景图
- (void)viewDidLoad
{
[super viewDidLoad];
[[self view]setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg_sand"]]];
}
//上边的导航栏 [sparrow]
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
@xxd
xxd / Curve.m
Created April 26, 2012 01:55
动画效果Animation收集:翻页,gif,按钮
//翻页效果
//经常看到iPhone的软件向上向下翻页面的效果,其实这个很简单,已经有封装好的相关方法处理。
//首先设置动画的相关参数
[UIView beginAnimati*****:@"Curl"context:nil];
[UIView setAnimationDuration:1.25]; //时间
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];//速度
//然后设置动画的动作和目标视图
[UIViewsetAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
//参数UIViewAnimationTransitionCurlUp代表向上翻页,如果向下的话UIViewAnimationTransitionCurlDown.
//forView那把当前的视图传进去。
@xxd
xxd / gist:2337709
Created April 8, 2012 14:48
SQLite Basic
//Open database
NSArray *documentsPaths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory
, NSUserDomainMask
, YES);
NSString *databaseFilePath=[[documentsPaths objectAtIndex:0] stringByAppendingPathComponent:@"mydb"];
if (sqlite3_open([databaseFilePath UTF8String], &database)==SQLITE_OK) {
NSLog(@"open sqlite db ok.");
}