This file contains hidden or 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
NSUInteger a = 0; | |
NSInteger b = 3; | |
NSInteger c = 1; | |
BOOL d = c >= a - b; //d is NO because a - b is implicitly converted to NSUInteger 4294967294 | |
NSString *string = @""; | |
BOOL e = c >= string.length - b; // e is NO because string.lenth returns NSUInteger. |
This file contains hidden or 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
self.newsFeedDescriptionLabel.font = nil; //without this line the font attribute may not apply to the label |
This file contains hidden or 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)viewDidLayoutSubviews | |
{ | |
self.containerView.frame = self.view.bounds; | |
self.currentVC.view.frame = self.containerView.bounds; | |
} | |
-(void)showChildViewController:(UIViewController *)childVC | |
{ | |
[self addChildViewController:childVC]; | |
self.containerView.frame = self.view.bounds; |
This file contains hidden or 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
To set the back button title for a view controller without changing it's title you use: | |
Objective-C: | |
self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:self.navigationItem.backBarButtonItem.style target:nil action:nil]; | |
Swift: | |
navigationItem.backBarButtonItem = UIBarButtonItem(title: "", style: .Plain, target: nil, action: nil) | |
To be clear, this is done on the view controller that you would see if you hit the back button. | |
i.e. instead of seeing '< Settings' you want to just see '<' then on your SettingsViewController you would put this in your init. |
This file contains hidden or 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
In UIViewController subclasses | |
-(void)viewDidLayoutSubviews | |
{ | |
self.containerView.frame = self.view.bounds; | |
self.currentVC.view.frame = self.containerView.bounds; | |
} | |
In UIView subclasses | |
-(void)layoutSubviews | |
{ |
This file contains hidden or 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)layoutSubviews | |
{ | |
[super layoutSubviews]; | |
.... | |
} |
This file contains hidden or 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)updateConstraints | |
{ | |
[super updateConstraints]; | |
if (self.binaryFiles.count > 0) | |
{ | |
//deactivate first, then activate, then change constant | |
[NSLayoutConstraint deactivateConstraints: @[self.attachmentButtonConstraintHeight]]; | |
[NSLayoutConstraint activateConstraints: @[self.attachmentButtonConstraintAspectRatio]]; | |
// self.attachmentButtonConstraintHeight.active = NO; | |
// self.attachmentButtonConstraintAspectRatio.active = YES; |
This file contains hidden or 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
CFDataRef imageData = (__bridge CFDataRef)[self getData]; | |
CGImageSourceRef imageSourceRef = CGImageSourceCreateWithData(imageData, nil); | |
CFDictionaryRef options = (__bridge CFDictionaryRef) @{ | |
(id) kCGImageSourceCreateThumbnailWithTransform : @YES, | |
(id) kCGImageSourceCreateThumbnailFromImageAlways : @YES, | |
(id) kCGImageSourceThumbnailMaxPixelSize : @(100)}; | |
CGImageRef imageRef = CGImageSourceCreateThumbnailAtIndex(imageSourceRef, 0 , options); | |
thumbnail = [UIImage imageWithCGImage: imageRef]; | |
return thumbnail; |
This file contains hidden or 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
id imageSource = cell.imageSource; | |
dispatch_async(queue, ^{ | |
//block captures imageSource | |
UIImage *thumbNail = getImageFromSource(imageSource); | |
dispatch_sync(dispatch_get_main_queue(), ^{ | |
//block captures cell | |
//if imageSource does not match cell.imageSource, it means the cell is resued before the background thread returns the image, | |
// and the image requested for the already invisible cell may be returned after the current cell obtains its image, in which case | |
// the returned image should not be used. | |
if ([imagaeSource isEqualToArray: cell.imageSource]) |
This file contains hidden or 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)viewWillAppear:(BOOL)animated | |
{ | |
//force the layout before the drawing cycle begins, so that when the tableview setup its cells the subviews of the cell | |
already have the frame information of the cell. For example, with this line, the text view inside the cell can use | |
the cell width to calculate depth to accormodate its text. | |
[self.view layoutIfNeeded]; | |
[self.tableView reloadData]; | |
} |
OlderNewer