在指导页面视图显示后如何进入MainStoryboard的初始视图?

时间:2013-12-27 03:30:02

标签: ios xcode storyboard

单击滚动视图中的按钮时,如何输入故事板的初始视图。

我的故事板包含以下内容:

[导航控制器] - > [TableView控制器] - > [DetailView控制器]

我的代码:

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window=[[UIWindow alloc]initWithFrame:[[UIScreen mainScreen]bounds]];

    [self GuidePage];
    return YES;
}


-(void)GuidePage
{
    UIScrollView *scro=[[UIScrollView alloc]initWithFrame:self.window.bounds];
    scro.pagingEnabled=YES;
    _currentScro=scro;
    scro.scrollEnabled=YES;
    scro.bounces=NO;
    scro.showsHorizontalScrollIndicator=NO;;
    scro.delegate=self;
    UIImageView *imgView1=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Guide1.png"]];
    imgView1.frame=CGRectMake(0, 0, 320, 480);
    UIImageView *imgView2=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"Guide2.png"]];
    imgView2.frame=CGRectMake(320, 0, 320, 480);

    UIButton *btnEnter= [[UIButton alloc] initWithFrame:CGRectMake(400, 200, 100, 100)];
    [btnEnter setTitle:@"Enter" forState:UIControlStateNormal];

    [scro addSubview:imgView1];
    [scro addSubview:imgView2];
    [scro addSubview:btnEnter];

    [btnEnter addTarget:self action:@selector(gotoMainStoryboard) forControlEvents:UIControlEventTouchUpInside];

    scro.contentSize=CGSizeMake(320*2, scro.frame.size.height);
    UIPageControl *page=[[UIPageControl alloc]initWithFrame:CGRectMake(0, 400, 320, 20)];
    page.numberOfPages=2;
    _pageControl=page;
    [page addTarget:self action:@selector(changeCurrentPage:) forControlEvents:UIControlEventValueChanged];
    page.backgroundColor=[UIColor redColor];
    page.currentPage=0;
    [self.window addSubview:scro];
    [self.window addSubview:page];
}

-(void) gotoMainStoryboard
{
    NSLog(@"goto");
}

-(void)changeCurrentPage:(UIPageControl *)sender
{
    [_currentScro setContentOffset:CGPointMake(sender.currentPage*320, 0)];
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if ((int)scrollView.contentOffset.x%320==0) {
        _pageControl.currentPage=(int)scrollView.contentOffset.x/320;
    }
}

@end

1 个答案:

答案 0 :(得分:0)

在你的

 -(void) gotoMainStoryboard
{
   [self performSegueWithIdentifier:@"segue name" sender:nil];
}

这将在按钮点击时带来下一个viewcontroller。