Wednesday, September 11, 2013

UIWebView local images

http://stackoverflow.com/questions/5329648/display-local-uiimage-on-uiwebview

Wednesday, July 24, 2013

Block example

в классе

- (NSArray *)loadTitles
{
    NSMutableSet *set = [NSMutableSet set];
    
    NSArray *lists = [List findAll];
    for (List *list in lists) {
        NSSet *titles = [list.items select:^id(id element) {
            ListItem *item = element;
            return item.title;
        }];
        
        [set addObjectsFromArray:titles.allObjects];
    }
    
    return [set.allObjects sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
}

- (void)loadTitlesWithAction:(ArrayBlock)action
{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        NSArray *titles = [self loadTitles];
        dispatch_async(dispatch_get_main_queue(), ^{
            if (action)
                action(titles);
        });
    });

}

вызов в другом классе
     // пример использования метода с блоком
    // вызываем метод и передаем блок, которые вызовется, когда метод закончится
    // в итоге получаем то же, что и с делегатом, но без мороки с делегатом
    self.allItemsInListForAutoComplete = [[AllItemsInList alloc] init];
    [self.allItemsInListForAutoComplete loadTitlesWithAction:^(NSArray *arr) {
        self.titleItemForAutoCompleteArray = arr.mutableCopy;
        [self.autocompleteTableView reloadData];
    }];


Tuesday, July 16, 2013

section UITableView not stopped

1) UITableViewStyleGrouped
2) tableView.backgroundView = nil;
3) в cellForRow...        
    cell.backgroundView = [[[UIView alloc] initWithFrame:cell.bounds] autorelease];
4) в layoutSubviews ячейки
    self.contentView.frame = self.bounds;

resize iPad

- (void)viewDidLoad
{
    [super viewDidLoad];
    
    smokeKillYou = [[UILabel alloc] initWithFrame:CGRectMake(0, self.view.frame.size.height - 108 , self.view.frame.size.width, 108)];
    smokeKillYou.numberOfLines = 1;
    smokeKillYou.font = [UIFont fontWithName:@"Arial" size:100];
    smokeKillYou.textColor = [UIColor blackColor];
#warning шрифт не тот
    smokeKillYou.text = @"TEST";
    smokeKillYou.textAlignment = NSTextAlignmentCenter;
//    smokeKillYou.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth;
    [self.view addSubview:smokeKillYou];
    [smokeKillYou release];
    }



-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];

    [self resizeWithInterfaceOrientation:toInterfaceOrientation];
}

- (void) resizeWithInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation
{
    CGFloat width = UIInterfaceOrientationIsLandscape(interfaceOrientation)? 1024 : 768;
    CGFloat height = UIInterfaceOrientationIsLandscape(interfaceOrientation)? 768 : 1024;
    
    smokeKillYou.frame = CGRectMake(0, height - 108 , width, 108);

}

Thursday, June 13, 2013

set gradient mask

- (void)setMask{
    
    CAGradientLayer *mask = [CAGradientLayer layer];
    mask.locations = @[@0.0, @0.80f, @0.98, @1.0f];
    
    mask.colors = @[
                    ( id)[UIColor whiteColor].CGColor,
                    ( id)[UIColor whiteColor].CGColor,
                    ( id)[UIColor clearColor].CGColor,
                    ( id)[UIColor clearColor].CGColor
                    ];
    
    
    mask.frame = _webView.bounds;
    mask.startPoint = CGPointMake(0, 0);
    mask.endPoint = CGPointMake(0, 1);
    
    _webView.layer.mask = mask;

}

Thursday, May 30, 2013

сортировка массива

     [_dataArray removeAllObjects];
    NSArray *athele = [sportResult.matchDetails objectForKey:@"athleteResults"];
    if ([athele isKindOfClass:[NSArray class]]) {
        [_dataArray addObjectsFromArray:[athele sortedArrayUsingComparator:^NSComparisonResult(id obj1, id obj2) {
            
            int rank1 = [[NSString validateString:[obj1 objectForKey:@"rank"]] integerValue];
            int rank2 = [[NSString validateString:[obj2 objectForKey:@"rank"]] integerValue];
            if(rank1 == 0) return NSOrderedDescending;
            if(rank2 == 0) return NSOrderedAscending;
            return [@(rank1) compare:@(rank2)];
            
        }]];
    }

проверить на соответствие одного объекта, объктам в массиве

      NSString *runningAthlete1 = [[[[sportResult.matchDetails objectForKey:@"unitInfo"] objectForKey:@"currentPair"] objectForKey:@"innerAthlete"] objectForKey:@"odfCode"];
            NSString *runningAthlete2 = [[[[sportResult.matchDetails objectForKey:@"unitInfo"] objectForKey:@"currentPair"] objectForKey:@"outerAthlete"] objectForKey:@"odfCode"];
            NSString *runningAthlete3 = [[[[sportResult.matchDetails objectForKey:@"unitInfo"] objectForKey:@"nextPair"] objectForKey:@"innerAthlete"] objectForKey:@"odfCode"];
            NSString *runningAthlete4 = [[[[sportResult.matchDetails objectForKey:@"unitInfo"] objectForKey:@"nextPair"] objectForKey:@"outerAthlete"] objectForKey:@"odfCode"];
            
            NSArray *currentAthletes = @[runningAthlete1,runningAthlete2,runningAthlete3,runningAthlete4];

            for (int i = 0; i < fullListAthletes.count; i++) {
                          
                if ([currentAthletes containsObject:[[[fullListAthletes objectAtIndex:i] objectForKey:@"athlete"] objectForKey:@"odfCode"]]) {
                    [fullListAthletes removeObjectAtIndex:i];
                    i--;
                }
                
                 NSLog(@"123");

            }

Wednesday, April 24, 2013

Sunday, April 21, 2013

UINavigationController to existing UIViewController

UIToolBar as inputAccessoryView for UITextView

right button to a UINavigationController

Border around UITextView

UINavigationViewController add in View

Localization App

Friday, April 12, 2013

http://www.cocoacontrols.com/

UILabel в цикле


NSUInteger i = 0;

for (i=0; i<[elements count]; i++){
   UILabel *label = [[UILabel alloc] init];
   NSString *tempName = [NSString stringWithFormat:@\"label%d\", i+1];
   label.tag = tempName;
   [label release]
}

Thursday, April 11, 2013

tag define


#define LABEL_TAG_OFFSET 100
#define LINE_TAG_OFFSET 200

  ((UIImageView*)[self.contentView viewWithTag:i +LINE_TAG_OFFSET]).image = [UIImage imageNamed:@"bluepolos.png"];

Monday, April 8, 2013

UILabel в цикле


NSUInteger i = 0;

for (i=0; i<[elements count]; i++){
   UILabel *label = [[UILabel alloc] init];
   NSString *tempName = [NSString stringWithFormat:@\"label%d\", i+1];
   label.tag = tempName;
   [label release]
}

UITableView. Hide cell, with button in section


UITableView: Display and hide cells as a dropdown list

layoutSubviews

Метод вызывается при работе с ячейкой в UITabliView

В нем можно переопределять фреймы, если например какого-то объеткта не пришло, каратинки например, тогда фрейм другого объеткра сменить

getter


-(UILabel *)scoreFirstLabel
{    
    if (!_scoreFirstLabel) {
        _scoreFirstLabel = [[[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(_winnerFierstImageView.frame) +1, CGRectGetMinY(_winnerFierstImageView.frame) +2, 20, 10)] autorelease];
_scoreFirstLabel.textColor = RGBA(32, 43, 68, 1);
_scoreFirstLabel.numberOfLines = 1;
_scoreFirstLabel.font = [UIFont fontWithName:@"EtelkaText" size:10];
_scoreFirstLabel.backgroundColor = [UIColor clearColor];
[self.contentView addSubview:_scoreFirstLabel];
    }
    return _scoreFirstLabel;
}

Tuesday, March 26, 2013

Бриф разработчика мобильных приложений

Cache URL images iphone UITableview

Возможности отладчика в Xcode 4.5 Debug

UITextView multiline

Хочешь быть iOS разработчиком? Будь им! Подборка

Objective C Data Caching on iOS

Saturday, March 23, 2013

Add UITextField Programmatically


CGRect textFieldFrame = CGRectMake(0.00.0100.030.0);
UITextField *txtField = [[UITextField allocinitWithFrame:textFieldFrame];
// default is UITextBorderStyleNone. If set to UITextBorderStyleRoundedRect, custom background images are ignored.

[txtField setBorderStyle:UITextBorderStyleRoundedRect];
[txtField setTextColor:[UIColor blackColor]];
[txtField setFont:[UIFont systemFontOfSize:20]];
[txtField setDelegate:self];
[txtField setPlaceholder:@"Add Your Placeholder Text Here"];
[txtField setBackgroundColor:[UIColor whiteColor]];
txtField.keyboardType = UIKeyboardTypeDefault;


http://ios.biomsoft.com/tag/uitextfield/

Thursday, March 21, 2013

header http


NSMutableURLRequest* request = [[[NSMutableURLRequest alloc] initWithURL:url]
                                autorelease];

[request setValue:VALUE forHTTPHeaderField:@"Field You Want To Set"];
or to add a header:
[request addValue:VALUE forHTTPHeaderField:@"Field You Want To Set"];
Accept: application/json, 

Wednesday, March 20, 2013

UINavigation Label


CGRect frame = CGRectMake(0, 0, 400, 44);
UILabel *label = [[[UILabel alloc] initWithFrame:frame] autorelease];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont [UIFont fontWithName:@"123Sans-Bold" size:12]];
label.textAlignment = UITextAlignmentCenter;
label.textColor = [UIColor whiteColor];
label.text = @"Sample custom Title With small Fonts ";
self.navigationItem.titleView = label;


label.font = [UIFont boldSystemFontOfSize:8.0];