首页 > 其他 > 详细

storyboard ID

时间:2015-03-10 06:46:33      阅读:290      评论:0      收藏:0      [点我收藏+]

The storyboard ID is a String field that you can use to create a new ViewController based on that storyboard ViewController. An example use would be from any ViewController:

//Maybe make a button that when clicked calls this method

- (IBAction)buttonPressed:(id)sender
{
    MyCustomViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyViewController"];

   [self presentViewController:vc animated:YES completion:nil];
}

This will create a MyCustomViewController based on the storyboard ViewController you named "MyViewController" and present it above your current View Controller

And if you are in your app delegate you could use

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
                                                         bundle: nil];

Edit: Swift

@IBAction func buttonPressed(sender: AnyObject) {
    let vc = storyboard?.instantiateViewControllerWithIdentifier("MyViewController") as MyCustomViewController
    presentViewController(vc, animated: true, completion: nil)
}

and

let storyboard = UIStoryboard(name: "MainStoryboard", bundle: nil)

storyboard ID

原文:http://www.cnblogs.com/welhzh/p/4324977.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!