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
| [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
| 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
| 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
| //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
| +(NSInteger)getRandomIntBetween:(NSInteger)min andMax:(NSInteger)max | |
| { | |
| return min + arc4random() % ((max + 1) - min); | |
| } |
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
| +(natural_t) getFreeMemory | |
| { | |
| mach_port_t host_port; | |
| mach_msg_type_number_t host_size; | |
| vm_size_t pagesize; | |
| host_port = mach_host_self(); | |
| host_size = sizeof(vm_statistics_data_t) / sizeof(integer_t); | |
| host_page_size(host_port, &pagesize); | |
| vm_statistics_data_t vm_stat; | |
| if (host_statistics(host_port, HOST_VM_INFO, (host_info_t)&vm_stat, &host_size) != KERN_SUCCESS) { |
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
| +(BOOL)orientationIsPortrait | |
| { | |
| return UIDeviceOrientationIsPortrait([[UIApplication sharedApplication] statusBarOrientation]); | |
| } | |
| + (UIInterfaceOrientation) interfaceOrientation | |
| { | |
| return [[UIApplication sharedApplication] statusBarOrientation]; | |
| } |
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
| +(NSString *)getTimeAgo:(NSDate *)fecha | |
| { | |
| NSString *timeAgo; | |
| float since_mins,since_hours, since_days, since_months, since_years; | |
| NSTimeInterval since = fabs([fecha timeIntervalSinceNow]); | |
| since_mins = (since / 60); | |
| since_hours = (since_mins / 60); | |
| since_days = (since_hours / 24); | |
| since_months = (since_days / 31); |
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
| + (CGPoint)getFirstTransparentPixelOfImage:(UIImage*)image | |
| { | |
| int xx = 0; | |
| int yy = 0; | |
| int count = image.size.width * image.size.height; | |
| // First get the image into your data buffer | |
| CGImageRef imageRef = [image CGImage]; |