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
//Vamos a observar la propiedad cartUnits del objeto _product | |
[_product addObserver:self forKeyPath:@"cartUnits" options:NSKeyValueObservingOptionNew|NSKeyValueObservingOptionOld context:nil]; | |
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context | |
{ | |
if([keyPath isEqualToString:@"cartUnits"]) | |
{ | |
//Acción | |
} | |
} |
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
CGSize expectedLabelSize = [yourString sizeWithFont:yourLabel.font | |
constrainedToSize:maximumLabelSize | |
lineBreakMode:yourLabel.lineBreakMode]; |
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
ProductView *v = [[[NSBundle mainBundle] loadNibNamed:@"ProductView" owner:self options:nil] objectAtIndex:0]; |
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
[UIView animateWithDuration:DURATION | |
delay:0.0 | |
options: UIViewAnimationCurveEaseOut | |
animations:^{ | |
} | |
completion:^(BOOL finished){ | |
}]; |
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
//Assuming the view controller's size is WIDTHxHEIGHT | |
//Calling the view Controller: | |
CustomViewController *vc = [[CustomViewController alloc] init]; | |
vc.modalPresentationStyle = UIModalPresentationFormSheet; | |
[self presentModalViewController:vc animated:YES]; | |
//In the view controller: | |
-(void)viewWillAppear:(BOOL)animated | |
{ |
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
// | |
// UIImage-Extensions.h | |
// | |
// Created by Hardy Macia on 7/1/09. | |
// Copyright 2009 Catamount Software. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
@interface UIImage (CS_Extensions) | |
- (UIImage *)imageAtRect:(CGRect)rect; |
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
// | |
// UIImage-Extensions.m | |
// | |
// Created by Hardy Macia on 7/1/09. | |
// Copyright 2009 Catamount Software. All rights reserved. | |
// | |
#import "UIImage-Extensions.h" | |
CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;}; |
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
static inline double radians (double degrees) {return degrees * M_PI/180;} |
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
Formula to find the width of UILabel with the text length | |
#define MY_LABEL_FONT_SIZE 18 | |
#define MY_LABEL_TEXT_WIDTH_MULTIPLIER(MY_LABEL_FONT_SIZE/2 + 1) | |
For example if we have a String of length 8 characters then we can find the width of the UILabel which can fit the text as : | |
8* MY_LABEL_TEXT_WIDTH_MULTIPLIER | |
and setting the Font Size of the UILabel text as MY_LABEL_FONT_SIZE |
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
- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath | |
{ | |
static NSString* customCellIdentifier = @"CustomCellIdentifier"; | |
CustomCell* cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:customCellIdentifier]; | |
if (cell == nil)// tableview not associated (registered) with nib file. | |
{ | |
UINib* customCellNib = [UINib nibWithNibName:@"CustomCell" bundle:nil]; // Register this nib file with cell identifier. | |
[tableView registerNib: customCellNib forCellReuseIdentifier:customCellIdentifier]; | |
} |