Ios 3秒钟后将视图重新定向到另一个视图

Ios 3秒钟后将视图重新定向到另一个视图,ios,iphone,objective-c,uiviewcontroller,storyboard,Ios,Iphone,Objective C,Uiviewcontroller,Storyboard,我使用xcode 5,1和ios 6,0为iphone创建应用程序 我想在3秒钟后创建一个包含我的应用程序名称的视图。此视图将重定向到另一个包含处理我的应用程序的视图 我的主故事板是这样的 在我的班级里我有 - (void)viewDidLoad { [super viewDidLoad]; NSLog(@"yesss"); Demmarage *d = [[Demmarage alloc] init]; [self.navigationController p

我使用xcode 5,1和ios 6,0为iphone创建应用程序

我想在3秒钟后创建一个包含我的应用程序名称的视图。此视图将重定向到另一个包含处理我的应用程序的视图

我的主故事板是这样的

在我的班级里我有

- (void)viewDidLoad
{
    [super viewDidLoad];
    NSLog(@"yesss");
    Demmarage *d = [[Demmarage alloc] init];
    [self.navigationController pushViewController:d animated:YES];
    NSLog(@"merdeee");
}
但当我构建应用程序时,什么都没有发生


如何执行我的应用程序我希望视图“icoz”保持3秒&在我希望在您的
FirstViewController中显示视图“myblan”之后

-(void)viewDidAppear:(BOOL)animated
{
 //push you secondview controller on GCD with delay
 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3*NSEC_PER_SEC)), dispatch_get_main_queue(),^{
  Demmarage *d = [[Demmarage alloc] init];
  [self.navigationController pushViewController:d animated:YES];

 });
}

在您的
FirstViewController

-(void)viewDidAppear:(BOOL)animated
{
 //push you secondview controller on GCD with delay
 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3*NSEC_PER_SEC)), dispatch_get_main_queue(),^{
  Demmarage *d = [[Demmarage alloc] init];
  [self.navigationController pushViewController:d animated:YES];

 });
}

首先,我看不出您的initialViewController是否是
UINavigationViewController
。如果不是,您的statemant
self.navigationController
为零,这可能是什么也没有发生的原因”

在您的故事板中,一个序列是可见的,您可以在
视图中延迟执行该序列

- (void)viewDidAppear:(BOOL)animated 
{
    [super viewDidAppear:animated];

    double delayInSeconds = 3.0; //seconds to wait
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [self performSegueWithIdentifier:@"TheNameOfTheSegue" sender:self];
    });
}
另一个选项(不带GCD和segue)是以下选项-只需使用导航控制器推动即可:

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(pushDemmarage:) userInfo:nil repeats:NO];
    //or use the following line instead of NSTimer
    //[self performSelector:@selector(pushDemmarage:) withObject:nil afterDelay:3];
}

-(void)pushDemmarage:(id)sender
{
    Demmarage *d = [[Demmarage alloc] init];
    [self.navigationController pushViewController:d animated:YES];
}

首先,我看不出您的initialViewController是否为
UINavigationViewController
。如果不是,则您的statement
self.navigationController
为零,这可能是什么也没有发生的原因。”

在您的故事板中,一个序列是可见的,您可以在
视图中延迟执行该序列

- (void)viewDidAppear:(BOOL)animated 
{
    [super viewDidAppear:animated];

    double delayInSeconds = 3.0; //seconds to wait
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [self performSegueWithIdentifier:@"TheNameOfTheSegue" sender:self];
    });
}
另一个选项(不带GCD和segue)是以下选项-只需使用导航控制器推动即可:

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(pushDemmarage:) userInfo:nil repeats:NO];
    //or use the following line instead of NSTimer
    //[self performSelector:@selector(pushDemmarage:) withObject:nil afterDelay:3];
}

-(void)pushDemmarage:(id)sender
{
    Demmarage *d = [[Demmarage alloc] init];
    [self.navigationController pushViewController:d animated:YES];
}

您可以使用
NSTimer
在第一个控制器中停留3秒钟。在第一个控制器中执行此操作

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(loadSecondViewController:) userInfo:nil repeats:NO];

}

-(void)loadSecondViewController:(id)sender
{
    [self performSegueWithIdentifier:SecondViewSegueIdentifier sender:self];

}

此处的
MPSecondViewSegueIdentifier
是第一视图控制器和第二视图控制器之间的分段

您可以使用
NSTimer
在第一控制器中停留3秒钟。在第一个控制器中执行此操作

-(void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(loadSecondViewController:) userInfo:nil repeats:NO];

}

-(void)loadSecondViewController:(id)sender
{
    [self performSegueWithIdentifier:SecondViewSegueIdentifier sender:self];

}
self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(callMethod) userInfo:nil repeats:NO];

-(void)callMethod
{

    // Do what u want here.
    Demmarage *d = [[Demmarage alloc] init];
    [self.navigationController pushViewController:d animated:YES];

}
此处
MPSecondViewSegueIdentifier
是第一视图控制器和第二视图控制器之间的分段

self.timer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(callMethod) userInfo:nil repeats:NO];

-(void)callMethod
{

    // Do what u want here.
    Demmarage *d = [[Demmarage alloc] init];
    [self.navigationController pushViewController:d animated:YES];

}
请尝试此代码

尝试此代码。

使用此

(void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;
用这个

(void)performSelector:(SEL)aSelector withObject:(id)anArgument afterDelay:(NSTimeInterval)delay;

你所说的“什么都没发生”是什么意思?你有没有得到要显示的初始视图?是的,我只有视图图标,之后什么都没有发生:(你所说的“什么都没有发生”?你有没有得到要显示的初始视图?是的,我只有视图图标,之后什么都没有发生:(