0

わずか5秒で表示されるモーダルビューコントローラー(changeviewcontroller)を実行していますが、その方法は?私が書く必要がある重要なコードは何ですか?

4

6 に答える 6

2

-performSelector:withObject:afterDelay:次の方法を使用します。

-(void)someButtonClicked:(id)sender
{
   [self performSelector:@selector(openController) withObject:nil afterDelay:5.0];
}

-(void)openController
{
    //present the view controller
    SomeViewController *ctrl = ....;
    [self present...];
}
于 2012-08-20T10:38:52.897 に答える
0

NSTimerクラスを調べてください。5秒間実行するように設定し、selecorを呼び出してビューを閉じます。それはすべてAppleのドキュメントにあります

于 2012-08-20T10:30:31.613 に答える
0

これを行う:

 [UIView animateWithDuration:5

 animations:^{ 
   //add you modal view here
 }];
于 2012-08-20T10:37:00.630 に答える
0
[NSTimer scheduledTimerWithTimeInterval:5.0 target:self selector:@selector(theSelector) userInfo:nil repeats:NO];

これでうまくいくはずです。右のセレクターを挿入するだけです。

于 2012-08-20T10:37:28.070 に答える
0

これを試してください:モーダルビューコントローラークラスにメソッドを作成して、モーダルビューコントローラーを閉じます。

-(void)dismissModal{
   [self dissmissModalViewController];
}

viewdidLoadメソッドから、5秒の遅延でこのメソッドを呼び出します。

-(void)viewDidLoad{
  [self performSelector @selector(dismissModal) afterDelay:5.0 ];

}

構文を確認してください。xcodeを使用していません。

于 2012-08-20T11:02:24.430 に答える
0

MVC(Model View Controller)の場合

    -(void)viewWillAppear:(BOOL)animated
  {
                 [self performSelector:@selector(CloseViewController) withObject:nil afterDelay:5.0];

}

    -(void)CloseViewController{

        [yourViewController dissmissModalViewController];
    }

ここで任意のビューを使用すると、次のように機能します

-(void)viewWillAppear:(BOOL)animated
{
        [self performSelector:@selector(hideView) withObject:nil afterDelay:5.0];
}
-(void)hideView{

    CATransition *animation = [CATransition animation];
    [animation setDelegate:self];   
    [animation setType:kCATransitionFromBottom];
    [animation setDuration:1.0];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                                  kCAMediaTimingFunctionEaseInEaseOut]];
    [[yourView layer] addAnimation:animation forKey:@"transitionViewAnimation"];
    yourView.hidden=YES;
}

上記では、MVCのImageviewInstedを使用しています。お役に立てば幸いです...:)

于 2012-08-20T11:14:45.850 に答える