This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIImage *)scaleImage:(UIImage*)image toResolution:(int)resolution { | |
CGImageRef imgRef = [image CGImage]; | |
CGFloat width = CGImageGetWidth(imgRef); | |
CGFloat height = CGImageGetHeight(imgRef); | |
CGRect bounds = CGRectMake(0, 0, width, height); | |
//if already at the minimum resolution, return the orginal image, otherwise scale | |
if (width <= resolution && height <= resolution) { | |
return image; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)textViewDidEndEditing:(UITextView *)txtView { | |
self.placeholderLabel.hidden = ([txtView.text length] > 0); | |
} | |
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView { | |
self.placeholderLabel.hidden = YES; | |
return YES; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifdef DEBUG | |
NSLog(@"Cell recursive description:\n\n%@\n\n", [cell performSelector:@selector(recursiveDescription)]); | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame) | |
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending) | |
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) | |
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending) | |
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ChatMessage *message = [chatMessages objectAtIndex:indexPath.row]; | |
CGFloat topMargin = (indexPath.row == 0) ? 18 : 0; | |
CGRect stringRect = [message.text boundingRectWithSize:CGSizeMake(200, MAXFLOAT) | |
options:NSStringDrawingUsesLineFragmentOrigin | |
attributes:@{ NSFontAttributeName : [UIFont fontWithName:CHAT_CELL_FONT size:14] } | |
context:nil]; | |
CGSize stringSize = CGRectIntegral(stringRect).size; | |
CGFloat bottomMargin = [self isMessageHasTail:indexPath.row] ? 30 : 20; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Replace your enum declarations, such as this one: | |
enum { | |
UITableViewCellStyleDefault, | |
UITableViewCellStyleValue1, | |
UITableViewCellStyleValue2, | |
UITableViewCellStyleSubtitle | |
}; | |
typedef NSInteger UITableViewCellStyle; | |
with the NS_ENUM syntax: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)setPhotoByURLString:(NSString *)URLString { | |
if (URLString) { | |
URLString = [URLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; | |
SDImageCache *imageCache = [SDImageCache sharedImageCache]; | |
[imageCache queryDiskCacheForKey:URLString done:^(UIImage *image, SDImageCacheType cacheType) | |
{ | |
if (image) { | |
NSLog(@"image not null!!"); | |
[self.photoView setImage:image]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ (UIImage *)scaleImageProportionally:(UIImage *)image { | |
if (MAX(image.size.height, image.size.width) <= DEFAULT_PHOTO_MAX_SIZE) { | |
return image; | |
} | |
else { | |
CGFloat targetWidth = 0; | |
CGFloat targetHeight = 0; | |
if (image.size.height > image.size.width) { | |
CGFloat ratio = image.size.height / image.size.width; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (IBAction)fbBtnTouchUp:(id)sender { | |
if(NSClassFromString(@"SLComposeViewController") != nil) { | |
if([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) { | |
SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook]; | |
[controller setInitialText:self.post.title]; | |
[controller addURL:[NSURL URLWithString:self.post.url]]; | |
[self presentViewController:controller animated:YES completion:Nil]; |
NewerOlder