0

ボタンを押すと、他のボタンが付いた新しいサブビューが追加されます。私はこのようにしました。

UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button addTarget: @selector(newView)];


- (void)newView
{
    UIView *newView = [[UIView alloc]initWithFrame:CGRectmake(0,0,100,100)];
    [self.view addSubview:newView];
}

ボタンを押すと、新しいビューが追加されます。IB でできるように、プッシュ セグエ モーダル スタイルを使用して、新しいビューをアニメーション化したいと考えています。どうすればプログラムでそれを行うことができますか?

4

3 に答える 3

3

あなたはそれを行うことができますperformSegueWithIdentifier、ここにコードがあります

- (void)newView
{
    //execute segue programmatically
    [self performSegueWithIdentifier: @"MySegue" sender: self];
}
于 2013-05-20T11:38:33.983 に答える
0

次のように新しいビューコントローラーを提示できます。

- (void)newView
{
     //Embed your new View into a plain UIViewController
     UIView *newView = [[UIView alloc]initWithFrame:CGRectmake(0,0,100,100)];
     UIViewController *yourNewViewController= [[UIViewController alloc] init];
     controller.view = newView;

    //Present it animated         
    [self presentViewController:yourNewViewController animated:YES completion:nil];
}

それが役に立てば幸い!:)

于 2013-05-20T12:01:20.420 に答える
0

このようなことを試してください。

- (void)newView
{

     [self.view addSubview:newView]
      newView.frame = // somewhere offscreen, in the direction you want it to appear    from
      [UIView animateWithDuration:10.0 
                 animations:^{
                     newView.frame = // its final location
      }];

}
于 2013-05-20T11:52:47.613 に答える