enter image description here我在一个ViewController中创建了4个UITableView。
例。 (主要UITableView,项目UITableView,问题UITableView,活动UITableView)。
主UITableView有10行,每行有一个按钮(项目,问题,活动)。当Project UITableView中的单击按钮将显示并选择Main UITableView和Project按钮中的任何值时,显示所选值。
答案 0 :(得分:0)
使用委托
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
table1.m文件中的在didSelectRowAtIndexPath 中
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//do what you do an then call
[self.delegate table1ViewControllerDidSelectRowAtIndexPath: indexPath];
}
表2中的
#import table1.h
#import "fa13ChooseListTableViewController.h"
@interface fa13ClubTableViewController : UITableViewController<MenuViewControllerDelegate>
@end
table2.m中的在viewDidLoad中你需要getTable1控制器实例并设置为其委托属性table2实例(self) 然后实现table1ViewControllerDidSelectRowAtIndexPath委托方法
-(void) table1ViewControllerDidSelectRowAtIndexPath:(UICollectionViewController *)controller {
//do what you need to do with data from table1
}
使用indexPath作为示例,您可以路径委派任何所需的对象。