[英]Getting text from table cell from one View controller to another View controller
having trouble getting a cell that is tapped and has a checkmark to send the cell text to another View Controller 无法获取被点击的单元格并带有选中标记以将单元格文本发送到另一个View Controller时遇到问题
here is my code for didSelectRowAtIndexPath
这是我的
didSelectRowAtIndexPath
代码
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
}
else {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}
I also have this inside a IBAction when the View Controller is dismissed: 当视图控制器被关闭时,我也可以在IBAction中使用它:
[self dismissViewControllerAnimated:YES completion:nil];
((FSPhotoProcessViewController *)self.presentingViewController).categoryResult.text = cell.textLabel.text;
When i press the button the app crashes, but if i comment out the presentingViewController line out, then its fine. 当我按下按钮时,应用程序崩溃,但是如果我注释掉presentingViewController行,那么它就可以了。
[UITabBarController categoryResult]: unrecognized selector sent to instance
wondering how to get the tapped cell text to another view 想知道如何将点击的单元格文本显示到另一个视图
thanks. 谢谢。
Do you need to dismiss the view controller? 您需要解雇视图控制器吗? You could just load the other one on top of it and then dismiss the new view controller to come back to where you are.
您可以将另一个加载在其顶部,然后关闭新的视图控制器以返回您所在的位置。
I had a similar problem and dismissing the main view controller was the issue. 我遇到了类似的问题,因此将主视图控制器排除在外了。
You need to pass texts as NSStrings(create a property in your destination view controller) and then in the viewWillAppear part of destination view controller you need to set UI parts from that NSString property. 您需要将文本作为NSStrings传递(在目标视图控制器中创建属性),然后在目标视图控制器的viewWillAppear部分中,您需要从该NSString属性设置UI部分。 This error occurs before you destination view controller's UI parts are not implemented until segue call.
在调用segue之前,未实现目标视图控制器的UI部件之前,会发生此错误。 Therefore you want to pass NSString to UI objects text property but you UI object is not created in the memory.
因此,您想将NSString传递给UI对象的text属性,但不会在内存中创建UI对象。
Example: 例:
((FSPhotoProcessViewController *)self.presentingViewController).myStringProperty = cell.textLabel.text;
Note: You can also pass numbers,arrays, dictionaries and your custom objects(not UI related). 注意:您还可以传递数字,数组,字典和自定义对象(与UI不相关)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.