Advertisement
Narayana

Picker

Dec 12th, 2011
3,696
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
IO 1.59 KB | None | 0 0
  1. actionSheet=[[UIActionSheet alloc] initWithTitle:@"" delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
  2.     [actionSheet showInView:self.view];
  3. UIToolbar *pickerToolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0,480,32)];
  4. [pickerToolbar sizeToFit];
  5.     pickerToolbar.barStyle = UIBarStyleBlackTranslucent;
  6. NSMutableArray *barItems = [[NSMutableArray alloc] init];
  7.    
  8.     UIBarButtonItem *cancelBtn = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonSystemItemCancel target:self action:@selector(cancel_clicked:)];
  9.     [barItems addObject:cancelBtn];
  10.     [cancelBtn release];
  11.     UIBarButtonItem *flexSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
  12.     [barItems addObject:flexSpace];
  13.     [flexSpace release];
  14.     UIBarButtonItem *doneBtn = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(done_clicked:)];
  15.     [barItems addObject:doneBtn];
  16.     [doneBtn release];
  17.     [pickerToolbar setItems:barItems animated:YES];
  18.     [actionSheet addSubview:pickerToolbar];
  19.     [barItems release];
  20.     [pickerToolbar release];
  21.  
  22. UIPickerView *picker = [[UIPickerView alloc] init];
  23. picker.frame = CGRectMake(0, 44, 320, 216);
  24. picker.delegate  = self;
  25.         picker.dataSource = self;
  26.         picker.showsSelectionIndicator = YES;
  27. [actionSheet addSubview:picker];
  28. [picker release];
  29.  
  30. -(void)done_clicked:(id)sender
  31. {
  32.     [actionSheet dismissWithClickedButtonIndex:0 animated:YES];
  33. }
  34. -(void)cancel_clicked:(id)sender
  35. {
  36.     [actionSheet dismissWithClickedButtonIndex:0 animated:YES];
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement