0

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];}
iNips
  • 23
  • 2
  • 5

3 Answers3

3

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; 
}

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;

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

self.yourStringProperty
sElanthiraiyan
  • 6,000
  • 1
  • 31
  • 38
1

Use the delegate concept for the communication between two classes.

The Basics of Protocols and Delegates

How do I set up a simple delegate to communicate between two view controllers?

Community
  • 1
  • 1
Jhaliya - Praveen Sharma
  • 31,697
  • 9
  • 72
  • 76
1
 NSUInteger row = [indexPath row];
 NSString value = [listOfItems objectAtIndex:row]; //use this code

 StatusViewController *detailViewController = [[StatusViewController alloc] initWithNibName:@"StatusViewController" bundle:nil];
detailViewController.label=value;
detailViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:detailViewController animated:YES];
[UIView commitAnimations];
[detailViewController release];

StatusViewController.h file

 NSString *label;
 @property (nonatomic, assign) NSString *label;

StatusViewController.m

 -(void) viewdidload{
      NSLog(@"%@",label);
  }
Kattu Poochi
  • 139
  • 1
  • 1
  • 7