how do I change the code below to fix the pickerView being depreciated?
This code has worked well before and did the job. I havent needed to compile for a while and when I was fixing another problem I bumped into this NSRangeException when it hits the subview. The code used to work with a previous version of IOS. Any thoughts would be appreciated.
Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
First throw call stack:... etc etc
After more reading I find that the pickerView is depreciated.
Never will understand why Apple can just change code!
-(void)willPresentActionSheet:(UIActionSheet *)actionSheet {
switch ([actionSheet tag] ) {
case 1://date
{
NSDate *d;
UIDatePicker *pickerView = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 50, 100, 116)];
[pickerView setTag:100+[actionSheet tag]];
[pickerView setDatePickerMode:UIDatePickerModeDate];
if( DefDate == @"" || DefDate == Nil ) DefDate = [fun0 GetCurrentDate];
d = [fun0 GetDatefromString:DefDate];
[pickerView setDate:d animated:YES];
[actionSheet addSubview:pickerView];
[pickerView release];
NSArray *subViews = [actionSheet subviews];
**// Line below is where is where it dumps:**
[[subViews objectAtIndex: SelectButtonIndex] setFrame:CGRectMake(20, 266, 280, 46)];
[[subViews objectAtIndex:CancelButtonIndex] setFrame:CGRectMake(20, 317, 280, 46)];
}
break;
}
}
- (IBAction)btnDate:(id)sender {
UIActionSheet *asheet = [[UIActionSheet alloc]
initWithTitle:@"Pick the date of your meal"
delegate:self
cancelButtonTitle:@""
destructiveButtonTitle:nil
otherButtonTitles:@"Select"
, nil];
[asheet setTag:1];
[asheet showInView:[self.view superview]];
[asheet setFrame:CGRectMake(0, 117, 320, 383)];
[asheet release];
}