代码之家  ›  专栏  ›  技术社区  ›  mmc

尝试订购内置uianimation,但没有太大成功

  •  1
  • mmc  · 技术社区  · 15 年前

    好的,我的iPhone应用程序中有一个屏幕,如下所示: sample screen http://matthewcave.com/images/iPhone.jpg

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

    现在,它一次为所有的东西设置动画(键盘永远不会消失,它只是改变外观,新的视图在键盘下以模式设置动画)。整个效果可以正常工作,但有点不自然,我认为在屏幕上弹出模态视图之前,先把键盘滑下来会更平滑。我看到过其他应用程序做我想做的事情(例如事情),所以我知道这是可能的。

    有人能给我指出正确的方向,让每个转换单独发生,而不是同时发生?

    编辑: 根据要求,这是我正在使用的一些代码。不幸的是,它在目标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];
    
    1 回复  |  直到 15 年前
        1
  •  3
  •   Amagrammer    15 年前

    认为 这应该有效:

    - (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        
    }
    

    在控制器中为您的编辑注释屏幕添加以下代码。如果您希望键盘在模式视图完全出现后重新启动动画,请将其放在VIEWDID显示中。否则,将相同的代码放入viewdidload或viewwill中。

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