0
我有一個表格視圖,顯示了一個模式中有幾個顯示開始日期和結束日期的靜態單元格。UIDatePicker沒有顯示在iPad上的靜態tableView中
當我點擊它們時,我想讓UIDatePicker顯示出來。目前,當我點擊該行時沒有任何反應。我錯過了什麼?
這裏是我的didSelectRowAtIndexPath方法:
- (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;
} }
我認爲在這個答案錯字。兩次都很弱:P – 2012-03-24 23:03:23
哈哈。德勤。現在修復它。 – Flaviu 2012-03-25 04:29:05