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]; |
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
- (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
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
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
#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
#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
- (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
+ (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
Представьте, что наш объект — это собака. Собака хочет «убежать» (освободить память). | |
Сильный указатель — это поводок с ошейником. Пока поводок прицеплен к ошейнику, собака не убежит. | |
Если 5 человек прицепят 5 поводков к одному ошейнику (5 указателей на 1 объект) — собака не убежит до тех пор, | |
пока не отцепят все 5 поводков. | |
А слабые указатели — это дети, которые тычут пальцем на собаку и кричат: «Ух ты, собака!» | |
Пока собака на поводке, они могут тыкать («указывать на объект») сколько угодно. | |
Но если отсоединить все поводки, то собака убежит, независимо от того, сколько детей тычут в неё пальцем. |
OlderNewer