有没有比我更博学的人能给我解释一下performSegueWithIdentifier:sender:?我需要切换视图(和类),还需要携带一些NSString和ID到该视图的类.我想知道这是否可能与performSegueWithIdentifier:sender:

谢谢

推荐答案

首先,你必须在故事板and give it the appropriate identifier中设置segue.(单击segue(左面板),然后单击Attributes(右面板).

然后,您可以将其链接到脚本中的按钮或表格行 Select ,也可以使用performSegueWithIdentifier:sender:在代码中调用它.

之后,视图控制器将收到prepareForSegue:sender:消息.在视图控制器子类中重写此方法,并可以按如下方式配置目标视图控制器:

TargetViewController *targetVC = (TargetViewController*)segue.destinationViewController;
targetVC.string1 = string1;

等等此方法中的sender将是用作原始方法调用中的sender的对象.

Objective-c相关问答推荐

Objective C中的简单字符串连接

XCTAssertEqual 错误:(3)不等于(3)

将类作为参数传递?

将 CSS 插入 UIWebView / WKWebView 中加载的 HTML

在 Interface Builder 中设计 UITableView 的section header

UISearchbar 键盘搜索按钮操作

iOS中CALayer的UIImage

UIScreen MainScreen Bounds 返回错误的大小

iOS NSLayoutConstraint 使用 constraintWithItem 固定宽度

无法加载从笔尖引用的图像

了解 performSegueWithIdentifier

声音在 iPhone 模拟器中不起作用?

在 Objective C 中使用 extern

如何将小时数添加到 NSDate?

在 NSArray 中查找最大数值

字符串常量和字符串文字有什么区别?

xcode 5.1 中的 Arm64 架构

找出用户是否按下了 uinavigationcontroller 中的后退按钮?

@synthesized 保留属性的释放是如何处理的?

@package 指令在 Objective-C 中的作用是什么?