试图订购内置的UIAnimations,但没有取得多大成功

问题描述 投票:1回答:1

好的,我的iPhone应用程序中有一个屏幕,如下所示:sample screen (来源:matthewcave.com

当触摸添加备注单元格时,我希望键盘消失,然后我希望它以模态方式显示编辑备注屏幕(它还有一个键盘,但我希望它能在屏幕上显示动画)。

现在它一次动画一切(键盘永远不会消失,它只是改变它的外观,并且新视图模态动画,似乎在键盘下面)。整个效果功能正常,但它有点笨拙,我认为在弹出屏幕上的模态视图之前滑动键盘会更顺畅。我已经看到其他应用程序做我想要的(例如),所以我知道它是可能的。

任何人都可以指出我正确的方向,使每个过渡单独发生,而不是一次完成吗?

编辑:根据要求,这里是我正在使用的一些代码。不幸的是,它在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];
iphone cocoa-touch iphone-sdk-3.0 core-animation
1个回答
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];
}
© www.soinside.com 2019 - 2024. All rights reserved.