Note that there are some explanatory texts on larger screens.

plurals
  1. POUIPickerView added to uitableviewcontroller.view won't rotate
    text
    copied!<p>I have a UIPickerView as subview in a UITableViewController, which I want to slide up in place when a certain row is clicked. I have implemented the necessary dataSource and delegate methods, but the pickerview acts weirdly. It acts as if it were mechanically jammed, it cannot rotate properly, it just moves a little. If I try to spin it a few times I get this message in the debugger console:</p> <blockquote> <p>SendDelegateMessage: delegate failed to return after waiting 10 seconds. main run loop mode: UITrackingRunLoopMode If you were not using the touch screen for this entire interval (which can prolong this wait), please file a bug.</p> </blockquote> <p>I googled for this, to no avail. Anyway, here is the relevant code. As you may guess, this is a number picker (to choose a percentage value).</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; percentPicker = [[UIPickerViewalloc] initWithFrame:CGRectMake(0,420, 320, 200)]; percentPicker.delegate = self; percentPicker.dataSource = self; percentPicker.showsSelectionIndicator = YES; [self.view addSubview:percentPicker]; } - (void)viewWillAppear:(BOOL)animated { // sets the rows to the appropriate value // etc } - (void)startEditingPercentage { [UIView beginAnimations :nilcontext:NULL]; [UIView setAnimationBeginsFromCurrentState:YES]; [UIViewsetAnimationDuration:kPickerAnimationDuration ]; percentPicker.transform = CGAffineTransformTranslate(CGAffineTransformIdentity, 0, -220.0); [UIViewcommitAnimations]; } - (void)stopEditingPercentage { NSLog(@"stopEditingPercentage"); [UIView beginAnimations :nilcontext:NULL]; [UIViewsetAnimationBeginsFromCurrentState:YES]; [UIViewsetAnimationDuration:kPickerAnimationDuration]; percentPicker.transform = CGAffineTransformIdentity; [UIView commitAnimations]; } #pragma mark UIPickerView delegate and dataSource methods - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return4; } - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return10; } - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { return44; } - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *retval = (UILabel *)view; if (!retval) { retval= [[UILabel newLabelWithPrimaryColor :[UIColorblackColor ] selectedColor:[ UIColor blackColor] fontSize:22bold:YEStransparent:YES] autorelease]; } retval.frame = CGRectMake(0, 0, 44, 44); retval.textAlignment = UITextAlignmentCenter; retval.backgroundColor = [UIColor clearColor]; retval.text = [NSStringstringWithFormat:@"%i", row]; if (component &gt; 1 ) { // rows 2 and 3 are decimal, white on black retval.backgroundColor = [UIColor blackColor]; retval.textColor = [UIColor whiteColor]; } return retval; } - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { NSString *selectedValue; selectedValue= [NSString stringWithFormat:@"%i%i.%i%i" ,[percentPickerselectedRowInComponent :0], [ percentPickerselectedRowInComponent: 1], [percentPickerselectedRowInComponent:2], [percentPickerselectedRowInComponent:3]]; NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init]; NSString *trimmedValue = [[formatter numberFromString:selectedValue] stringValue]; percentValue.text = trimmedValue; [formatter release]; } </code></pre> <p>As you see, I use the transform property to move the picker in and out (down) my main view; the startEditing and stopEditing methods are triggered by selection in the teble view. Yet, for the debugging purposes, I eliminated these transitions , and left the picker on top of the table, but nothing changed. I also commented the didSelect method, but this also didn't change anything. By the way, the same picker-view construction code vorkw allright in another view of the same app. Any suggestion? Cheers,</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload