2009-08-03 15 views
1

OK,我有一個畫面在我的iPhone應用程序,如下所示: sample screen http://matthewcave.com/images/iPhone.jpg試圖訂購內置UIAnimations,沒有多少成功

當筆錄細胞被觸摸時,我想的鍵盤消失,那麼我希望它以模態方式顯示編輯筆記屏幕(它也有一個鍵盤,但我希望它在屏幕上回放)。

現在它可以一次完成所有動畫(鍵盤永不消失,它只是改變它的外觀,並且新的視圖模擬地動畫,看起來在鍵盤下面)。整個效果功能正常,但它有點生氣,我認爲在彈出屏幕上的模式視圖之前滑動鍵盤會更平滑。我已經看到其他應用程序做我想做的事情(例如,事情),所以我知道這是可能的。

任何人都可以指出我在正確的方向使每個過渡單獨發生,而不是一次全部發生?

編輯:根據要求,這裏是我使用的一些代碼。不幸的是,它在Objective C中與在英語中幾乎完全相同。

UITableViewController* tableViewController = (UITableViewController*)tableView.dataSource; 

    AddNotesViewController* addNotesViewController = [[AddNotesViewController alloc] initWithWine:[self myWine]]; 

    UINavigationController* addNotesNavController = [[[UINavigationController alloc] initWithRootViewController:addNotesViewController] autorelease]; 

    // tell the name override cell to resign if they need to 
    [(NewWineViewController*)tableView.dataSource resignNameCell]; 

    //I'd like the animation caused by the resign to complete before proceeding. 

    [tableViewController.navigationController presentModalViewController:addNotesNavController animated:YES]; 
+0

你可以發佈你現在有的代碼片段嗎? – 2009-08-03 05:18:38

回答

3

認爲這應該工作:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITextField *textField = // the field that the keyboard is up for 
    [textField resignFirstResponder]; 

    NSTimeInterval delay = 2.0; // i.e., until keyboard has disappeared 
    [self performSelector: @selector(transitionToEditNotesScreen) withObject: nil afterDelay: delay]; 
} 

- (void) transitionToEditNotesScreen 
{ 
    // the code you have above to bring on the modal view controller   
} 

添加以下代碼在控制器爲您編輯備註屏幕。如果您希望在模式視圖完全出現後重新啓動鍵盤,請將其置於viewDidAppear中。否則,將相同的代碼放在viewDidLoad或viewWillAppear中。

- (void) viewDidAppear: (BOOL) animated 
{ 
    UITextField *textField = // the field you want the keyboard to be up for 
    [textField becomeFirstResponder]; 
} 
+0

這很好,謝謝。 – mmc 2009-08-04 17:30:19