从XIB中的按钮执行segue [英] Perform segue from button in XIB

查看:115
本文介绍了从XIB中的按钮执行segue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目的大部分时间都使用了故事板,但我有一个UIScrollView,它包含从XIB加载的多个视图

I'm using storyboards for the most of my project, but i have one UIScrollView that consists of multiple views that are loaded from XIB

我被困在如何在XIB中单击按钮时执行segue

I'm stuck on how to perform a segue when a button is clicked in the XIB

我已经完成了什么。


  • 将视图添加到滚动视图

  • 添加了自定义按钮

  • 在自定义按钮上添加了IBAcion

MainViewController

MainViewController

NSString *nibName = @"coverArticleView";
NSArray *nibObjects = [NSBundle.mainBundle loadNibNamed:nibName owner:self options:nil];
coverArticle *pageView = [nibObjects objectAtIndex:0];
pageView.articleTitle.text = ob.Title;
pageView.articleTitle.numberOfLines =0;
// updating some more properties here & designing the scroll view
[coverArticlesScrollView addSubview:pageView];

coverArticle.m(XIB类)

coverArticle.m (class of the XIB)

- (IBAction)buttonPressed:(id)sender {
NSLog(@"button pressed");
}

当打印日志'按钮'时,它正在工作。
但按下按钮时如何执行segue?

When the log 'button pressed' is printed so that's working. But how do i perform a segue when the button is pressed ?

thnx

推荐答案

如何 performSegueWithIdentifier:发件人:

这篇关于从XIB中的按钮执行segue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆