如何在不按任何按钮或任何操作的情况下自动从一个视图更改/转换到另一个视图

时间:2014-10-16 16:31:53

标签: ios objective-c uiviewcontroller uiviewanimation uiviewanimationtransition

如何自动更改/从一个视图转换到另一个视图,无需按下按钮或任何操作,只需一段时间后,在Xcode / Objective-C中说2,3秒,代码将如何显示,以及在何处写吧?

1 个答案:

答案 0 :(得分:0)

基本解决方案可能如下所示:

- (void)viewDidLoad
{
    [super viewDidLoad];

    // create and position the subviews, if necessary
    self.subview1 = ...
    self.subview2 = ...
    self.view addSubview:self.subview1];
    self.view addSubview:self.subview2];
}

- (void)viewWillAppear
{
    [super viewWillAppear];
    [self showFirstView];
}

- (void)showFirstView
{
    self.subview1.hidden = NO;
    self.subview2.hidden = YES;
    [self performSelector:@selector(showSecondViewView) withObject:nil afterDelay:5];
}

- (void)showSecondViewView
{
    self.subview1.hidden = YES;
    self.subview2.hidden = NO;
}