2012-03-23 13 views
0

テーブルビューは、開始日と終了日を示す静的なセルが2つあるモーダルで表示されます。iPadのstatic tableViewにUIDatePickerが表示されない

私がそれらをクリックすると、UIDatePickerが表示されます。現在、行をクリックすると何も起こりません。私は何が欠けていますか?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath]; 
    self.pickerView.date = [self.dateFormatter dateFromString:selectedCell.detailTextLabel.text]; 

    // check if date picker already on screen 
    if (self.pickerView.superview == nil) { 
     [self.view.window addSubview:self.pickerView]; 

     // size up the picker view to fit our screen and compute animation 
     // 
     //compute the start frame 
     CGRect screenRect = [[UIScreen mainScreen] applicationFrame]; 
     CGSize pickerSize = [self.pickerView sizeThatFits:CGSizeZero]; 
     CGRect startRect = CGRectMake(0.0, 
             screenRect.origin.y + screenRect.size.height, 
             pickerSize.width, 
             pickerSize.height 
             ); 
     self.pickerView.frame = startRect; 

     //computer end frame 
     CGRect pickerRect = CGRectMake(0.0, 
             screenRect.origin.y + screenRect.size.height - pickerSize.height, 
             pickerSize.width, 
             pickerSize.height 
             ); 
     // start the slide up animation 
     [UIView beginAnimations:nil context:NULL]; 
      [UIView setAnimationDuration:0.3]; 

      // we need to perform some post operations after the animation is complete 
      [UIView setAnimationDelegate:self]; 

      self.pickerView.frame = pickerRect; 

      // shrink the table vertical size to make room for the date picker 
      CGRect newFrame = self.tableView.frame; 
      newFrame.size.height -= self.pickerView.frame.size.height; 
      self.tableView.frame = newFrame; 
     [UIView commitAnimations]; 

     // add the "Done" button to the nav bar 
     self.navigationItem.rightBarButtonItem = self.doneButton; 
    } } 

答えて

0

愚かなミス:

は、ここに私のdidSelectRowAtIndexPathです。私はpickerViewプロパティは私のヘッダファイルで代わりに強いの弱い設定していた:

この:

@property (weak, nonatomic) IBOutlet UIDatePicker *pickerView; 

は、実際にはこのようになります。

@property (strong, nonatomic) IBOutlet UIDatePicker *pickerView; 
+0

私はこの答えにタイプミスがあると思います。あなたは両方の時間が弱かった:P –

+0

haha​​。タッチ。今それを修正しました。 – Flaviu

関連する問題