Baskar
Baskar

Reputation: 23

How to reload tableView with another tableView selected row values?

enter image description hereI have created 4 UITableView in a single ViewController.
Ex. (Main UITableView, Project UITableView, Issue UITableView, Activity UITableView).

Main UITableView has 10 rows with a button in every row(project, issue, activity). When click button in Project UITableView will show and select anyone values in Main UITableView and Project button show on selected values.

Upvotes: 0

Views: 118

Answers (1)

Sandr
Sandr

Reputation: 189

Use delegate

in table1.h

@protocol Table1Delegate;

@interface Table1ViewController : UIViewController
@property (nonatomic, weak) id < Table1Delegate > delegate;

@end

@protocol Table1Delegate
@required

@optional
    -(void) table1ViewControllerDidSelectRowAtIndexPath:(NSIndexPath *)indexPath;

@end


@interface table1ViewController : UITableViewController 

@property (nonatomic, weak) id < Table1Delegate > delegate;
@end

in table1.m file

in didSelectRowAtIndexPath

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//do what you do an then call
 [self.delegate table1ViewControllerDidSelectRowAtIndexPath: indexPath];

}

in table2.h

#import table1.h
#import "fa13ChooseListTableViewController.h"

@interface fa13ClubTableViewController : UITableViewController<MenuViewControllerDelegate>
@end

in table2.m in viewDidLoad you need to getTable1 controller instance and set to its delegate property table2 instance (self) then implement table1ViewControllerDidSelectRowAtIndexPath delegate method

-(void) table1ViewControllerDidSelectRowAtIndexPath:(UICollectionViewController *)controller {
//do what you need to do with data from table1

}

indexPath was used as an example, you can path to delegate any object you want.

Upvotes: 0

Related Questions