cask是基于homebrew的扩展命令,直接通过命令行去安装Mac的各种软件。免去之前通过下载链接下载DMG文件,然后拖动到Applitions目录,这种手动的安装方法。如果配置一部新的Mac机器,主要安装了cask,通过一个脚本就安装把用到软件一一安装上去,可以节约很多时间。
- Command Line Tools
- homebrew
/* | |
在nib文件中设置autolayout,设置 parentView 和 childView 之间的 top space,然后根据横竖屏来调整 top space大小 | |
*/ | |
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration | |
{ | |
if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation)){ | |
[self adjustTopSpace:100.0f]; | |
}else{ | |
[self adjustTopSpace:300.0f]; |
https://github.com/supermarin/Alcatraz
curl -fsSL https://raw.github.com/supermarin/Alcatraz/master/Scripts/install.sh | sh
- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch | |
{ | |
if ([gestureRecognizer isEqual:self.tapRecognizer]) { | |
// for ios 7 , need to compare with UITableViewCellContentView | |
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"] || [touch.view.superview isKindOfClass:[UITableViewCell class]]) { | |
return FALSE; | |
} | |
} | |
return TRUE; | |
} |
// information comes from http://stackoverflow.com/questions/3339722/how-to-check-ios-version | |
//------------------------------------- | |
// you can use this in your code | |
if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) { | |
// Load resources for iOS 6.1 or earlier | |
} else { | |
// Load resources for iOS 7 or later | |
} |
-(BOOL)dataIsValidJPEG:(NSData *)data | |
{ | |
if (!data || data.length < 2) return NO; | |
NSInteger totalBytes = data.length; | |
const char *bytes = (const char*)[data bytes]; | |
return (bytes[0] == (char)0xff && | |
bytes[1] == (char)0xd8 && | |
bytes[totalBytes-2] == (char)0xff && |
// src : file's url | |
// file : file's name on the disk | |
// return : file's path on the disk | |
- (NSString*)catchFileFrom:(NSString*)src toFile:(NSString*)file | |
{ | |
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); | |
NSString *filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],file]; | |
NSURL *url = [NSURL URLWithString:src]; |
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
Contact* contact = [self.contacts objectAtIndex:indexPath.row]; | |
UITableViewCell *cell = nil; | |
static NSString *cellId = @"Cell"; | |
cell = (UITableViewCell*)[tableView dequeueReusableCellWithIdentifier:cellId]; | |
if (cell == nil) { | |
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId] autorelease]; | |
} | |
UILabel *firstLabel = [[UILabel alloc] initWithFrame:CGRectZero]; |