Skip to content

Instantly share code, notes, and snippets.

View mactive's full-sized avatar
🎯
Focusing

mactive mactive

🎯
Focusing
View GitHub Profile
@mactive
mactive / gist:4010413
Created November 4, 2012 05:17
UIKeyBordType
textView.keyboardtype = UIKeyboardTypeNumberPad;
typedef enum {
UIKeyboardTypeDefault, // 默认键盘:支持所有字符
UIKeyboardTypeASCIICapable, // 支持ASCII的默认键盘
UIKeyboardTypeNumbersAndPunctuation, // 标准电话键盘,支持+*#等符号
UIKeyboardTypeURL, // URL键盘,有.com按钮;只支持URL字符
UIKeyboardTypeNumberPad, //数字键盘
UIKeyboardTypePhonePad, // 电话键盘
UIKeyboardTypeNamePhonePad, // 电话键盘,也支持输入人名字
UIKeyboardTypeEmailAddress, // 用于输入电子邮件地址的键盘
@mactive
mactive / gist:4022540
Created November 6, 2012 04:25
section index uitebleview 右侧快速索引
/////////////////////////////////////////////////////////////////////////////
#pragma mark - right section index
/////////////////////////////////////////////////////////////////////////////
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
NSArray *newarr=[[contacts_list_fix allKeys] sortedArrayUsingFunction:SortIndex context:NULL];
return newarr;
}
@mactive
mactive / gist:4065399
Created November 13, 2012 11:56
如何让 UITableView 的 headerView跟随 cell一起滚动
//The way I solved this problem is to adjust the contentOffset according to the contentInset in the //UITableViewControllerDelegate (extends UIScrollViewDelegate) like this:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
CGFloat sectionHeaderHeight = 40;
if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
} else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
}
}
@mactive
mactive / gist:4248926
Created December 10, 2012 06:59
方法整理:3.ARC 下加载第三方SDK,组件 (IOS iPhone Object-C)
由于现在大部分SDK,第三方组件都是 ios5之前发布的, 所以都不会用到ARC
但是如果我想使用苹果新的特性ARC的话,难道要手动改那些组件,sdk?
no, 其实有个超简单的方法,
xcode 中 点选你的项目 ---> Bulid Phases ---> Compile Source
然后选择 那些没有使用ARC的 sdk 或者 组件 的.m文件,
加上 -fno-objc-arc 这个flag
这样这个文件在编译的时候就不会使用ARC
@mactive
mactive / gist:4293948
Created December 15, 2012 11:27
iOS 首屏的图标圆角究竟是多少
http://stcui.me/202-ios-%E9%A6%96%E5%B1%8F%E7%9A%84%E5%9B%BE%E6%A0%87%E5%9C%86%E8%A7%92%E7%A9%B6%E7%AB%9F%E6%98%AF%E5%A4%9A%E5%B0%91/
在图标的设计中会在ps上画出一个Demo来查看最终的效果,这里就需要自己绘制一个圆角的蒙板或者用其它方法来完成这一效果,这个圆角的半径究竟是多少呢?
在早期的iPhone/iPod中图标尺寸为57×57圆角半径为10px
之后的版本中的图标尺寸就是按照这个比例来缩放的
如果是114×114的图标圆角半径为 114*(10/57) = 20
其它的一些例子:
Icon512.png – 512px – 89.8245614035098
@mactive
mactive / gist:4350702
Created December 21, 2012 04:57
UINavigationController 默认返回按钮时候 做一些操作
- (void)viewWillDisappear:(BOOL)animated
{
if ([self.navigationController.viewControllers indexOfObject:self]== NSNotFound) {
// back button was pressed. We know this is true because self is no longer
// in the navigation stack.
[self setEditMode];
}
[super viewWillDisappear:animated];
}
@mactive
mactive / gist:5114487
Created March 8, 2013 05:55
Snow leopard Xcode Icon already includes gloss effects not work
As you already got your answer, for users of Xcode 4.2 (Snow leopard) Dinesh's solution won't work. Here you can right-click on the info.plist file, and open as source code.
Look for this, and replace <false/> with <true/> under <key>UIPrerenderedIcon</key>
<dict>
<key>CFBundlePrimaryIcon</key>
<dict>
<key>CFBundleIconFiles</key>
<array>
<string>iconNormal.png</string>
@mactive
mactive / gist:5150822
Created March 13, 2013 10:15
想利用一个Coredata 的Model 但又不想写入数据库
//http://stackoverflow.com/questions/3868514/is-there-a-way-to-instantiate-a-nsmanagedobject-without-inserting-it
NSEntityDescription *entity = [NSEntityDescription entityForName:@"Transaction" inManagedObjectContext:self.managedObjectContext];
transaction = (Transaction *)[[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:nil];
@mactive
mactive / gist:5162124
Created March 14, 2013 15:10
如何导出个人开发者私钥
1.在Keychain Access中选择证书和private key
2.导出p12文件 输入导出密码
3.在目标机器双击导入
@mactive
mactive / gist:5386287
Created April 15, 2013 07:07
didRegisterForRemoteNotificationsWithDeviceToken not call back
如果后来开启的 develop and product push服务
那么需要重新生成一下Provisioning Profiles