也许最好的解决办法是编码的协议。
在myProtocol.h
@protocol myProtocol
-(void) didSelectItem: (id) yourItem;
@end
然后,在的viewController的接口文件,其中包含您的tableView:
@interface MyViewController : UIViewController {
id <myProtocol> selectionDelegate;
}
@property (nonatomic, assign) id <myProtocol> selectionDelegate;
在.m文件:
@synthesize selectionDelegate;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//do something with your data and pass it to the delegate.
[self.selectionDelegate didSelectItem:myObject];
[self.navigationController popViewControllerAnimated:YES];
}
包含按钮和标签必须执行的viewController您的代理人:
In .h:
@interface OtherViewController : UIViewController <myProtocol> {
...
}
在.M:
-(void) didSelectItem: (id) yourItem
{
//do something with your item, set the label and everything...
}
在你的代码的某些部分,你将不得不设置委托
希望这有助于
您可以使用一个委托协议这一点。如果您需要,我可以向您展示一个例子。 – TommyG
是的,这将是伟大的 – Illep
你刚刚从恩德得到它......应该这样做。 – TommyG