Привет всем, у меня странная проблема с UIPickerview + UIButton .. Я создал проект с xcode 4.2.Я добавляю UIPickerview с 2 компонентами в 1-й компонент, добавляю метку и 2-й компонент, добавляю кнопку, при нажатии кнопки мне нужно перейти в другой вид.все работает нормально в симуляторе и устройствах iOS 5, но не работает в устройствах, которые имеют версию ниже iOS 5. Мой код здесь
- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
UIView *tempView;
if(component==1)
{
tempView=[[UIView alloc] initWithFrame:CGRectMake(0, 0,60, 50)];
UIButton *_btnYou=[UIButton buttonWithType:UIButtonTypeCustom];
[_btnYou setFrame:CGRectMake(5, 0,55, 50)];
[_btnYou setImage:[UIImage imageNamed:@"icon_i.png"] forState:UIControlStateNormal];
[_btnYou setImage:[UIImage imageNamed:@"icon_u.png"] forState:UIControlStateHighlighted];
[_btnYou addTarget:self action:@selector(GoToRegistrationPage:) forControlEvents:UIControlEventTouchDown];
[tempView addSubview:_btnYou];
[_btnYou setUserInteractionEnabled:YES];
return tempView;
//return _btnYou;
}
else
{
tempView=[[UIView alloc] initWithFrame:CGRectMake(0, 0,168, 50)];
if(!([[dates objectAtIndex:row] isEqualToString:@"Today"]||[[dates objectAtIndex:row] isEqualToString:@"Idag"])){
//add days
UILabel *lab=[[UILabel alloc] initWithFrame:CGRectMake(3, 0,54, 50)];
[lab setBackgroundColor:[UIColor clearColor]];
[lab setTextColor:[UIColor grayColor]];
[lab setTextAlignment:UITextAlignmentRight];
[lab setFont:[UIFont fontWithName:@"Helvetica" size:20]];
[lab setFont:[UIFont boldSystemFontOfSize:20]];
lab.text=[[[dates objectAtIndex:row] componentsSeparatedByString:@","] objectAtIndex:0];
[tempView addSubview:lab];
}
//add month
UILabel *labDate=[[UILabel alloc] initWithFrame:CGRectMake(62, 0,106, 50)];
[labDate setBackgroundColor:[UIColor clearColor]];
[labDate setTextColor:[UIColor blackColor]];
[labDate setTextAlignment:UITextAlignmentLeft];
[labDate setFont:[UIFont fontWithName:@"Helvetica" size:25]];
[labDate setFont:[UIFont boldSystemFontOfSize:25]];
if(([[dates objectAtIndex:row] isEqualToString:@"Today"]||[[dates objectAtIndex:row] isEqualToString:@"Idag"])){
[labDate setTextColor:[UIColor greenColor]];
[labDate setTextAlignment:UITextAlignmentCenter];
labDate.text=[dates objectAtIndex:row];
}else{
labDate.text=[[[dates objectAtIndex:row] componentsSeparatedByString:@","] objectAtIndex:1];
}
[tempView addSubview:labDate];
}
return tempView;
}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
return 2;
}
-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
if(component == 0)
return [dates count];
else if(component == 1)
return 4;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component
{
if(component == 0)
return 168.0;
else if(component == 1)
return 66.0;
}
- (CGFloat)pickerView:(UIPickerView *)pickerView rowHeightForComponent:(NSInteger)component
{
return 50.0;
}
- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
notificationDate=[dates objectAtIndex:[pickerView selectedRowInComponent:0]];
NSLog(@"%@", [dates objectAtIndex:[pickerView selectedRowInComponent:0]]);
}
-(void)GoToRegistrationPage:(id)sender
{
NSLog(@"This is GoToRegistrationPage Button");
}
Метод GoToRegistrationPage не вызывает устройства (версия