jueves, 29 de agosto de 2013

Mostrar una vista modal de izquierda a derecha

Para abrir la ventana
CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];
[self presentModalViewController:viewCtrl animated:NO];



Para cerrar la ventana cambiamos la llamada:

[self presentModalViewController:viewCtrl animated:YES];


Por


CATransition *transition = [CATransition animation];
transition.duration = 0.3;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromRight;
[self.view.window.layer addAnimation:transition forKey:nil];

[self presentModalViewController:viewCtrl animated:NO];

miércoles, 28 de agosto de 2013

Poner una imagen en un control UIPickerView

Hay que utilizar este metodo en lugar del que solo devuelve el texto.

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
     NSString *t=@"";
     UIView *tmpView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 280, 32)];
    UILabel *channelLabel = [[UILabel alloc] initWithFrame:CGRectMake(30, 0, 250, 25)];
             t=def.funciones[row];
               UIImage *img = [UIImage imageNamed:@"Nombredelaimagen"];
             UIImageView *temp = [[UIImageView alloc] initWithImage:img];
             temp.frame = CGRectMake(0, 0, 25, 25);
                [tmpView insertSubview:temp atIndex:0];
     channelLabel.text = @"El texto que quieres";
    [channelLabel adjustsFontSizeToFitWidth];
    channelLabel.textAlignment = UITextAlignmentLeft;
    channelLabel.backgroundColor = [UIColor clearColor];
    [tmpView insertSubview:channelLabel atIndex:0];
   
    return tmpView;


}

Como detectar el dispositivo y el idioma

Para detectar el idioma:
NSString *locale = [[NSLocale currentLocale] localeIdentifier]; // en_US

Para detectar el dispositivo:
 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        if (altopantalla == 568)
        {
            //es un iphone 5
            
        }
        else
        {
            //es un iphone
            
        }
    } else {
       //es un ipad
    }