如何将tableview单元格值传递给另一个页面(uiviewcontroller)? [英] How to pass a tableview cell value to another page(uiviewcontroller)?

查看:99
本文介绍了如何将tableview单元格值传递给另一个页面(uiviewcontroller)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哈,我每个人都有一个包含一些值的tabeview单元格。如果用户点击其中一个单元格,则会出现一个带按钮的子视图,并在popoup中有一个名为save的按钮。我需要的是当用户点击保存按钮时它使用单元格的值重定向到保存页面,并在保存页面的textview中显示。这是我重定向到保存页面的代码。

Ha ii,everybody i have a tabeview cell containing some values.if the user tap one of the cell a subview with buttons appears and there in popoup i have a button named save.My need is when the user tap the save button it redirect to the save page with the value of the cell,and show it in the textview of the save page.This is my code for redirecting to save page.

-(IBAction)buttonclick{
StatusViewController *detailViewController = [[StatusViewController alloc] initWithNibName:@"StatusViewController" bundle:nil];

    detailViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:detailViewController animated:YES];
    [UIView commitAnimations];
    [detailViewController release];}


推荐答案

商店类中NSString值中单元格的字符串值。

Store the string value of the cell in the NSString value in the class.

如果需要上次选择的表格视图单元格中的字符串值。从委托方法获取字符串值,

If you want the string value from the last selected table view cell. Get the string value from the delegate method,

NSString *localStringValue;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{
  localStringValue = [tableView cellForRowAtIndexPath:indexPath].textLabel.text; 
}

在StatusViewController中创建NSString属性。

Create a NSString property in the StatusViewController.

@interface StatusViewController : UIViewController {

}
@property(nonatomic, retain) NSString *yourStringProperty;

如下所示更改您的代码,

alter your code as below,

StatusViewController *detailViewController = [[StatusViewController alloc] initWithNibName:@"StatusViewController" bundle:nil];

detailViewController.yourStringProperty = localStringValue;

在StatusViewController类中,您可以使用

in StatusViewController class you could access the string value by using,

self.yourStringProperty

这篇关于如何将tableview单元格值传递给另一个页面(uiviewcontroller)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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