[英]sending data from DetailViewController to MasterViewController
This is what exactly I'm trying to do. 这正是我想做的。
wizardviewcontroller.m wizardviewcontroller.m
- (IBAction)onCountryClick:(id)sender {
MJDetailViewController *detailViewController = [[MJDetailViewController alloc] initWithNibName:@"MJDetailViewController" bundle:nil];
[self presentPopupViewController:detailViewController animationType:MJPopupViewAnimationSlideLeftRight];
}
User click country button a popup shows with list. 用户单击国家/地区按钮,将显示一个带有列表的弹出窗口。
when user select a row button title should change. 当用户选择一个行按钮时,标题应更改。
This is my detailview, 这是我的局部视图
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath {
WizardViewController *mj = [[WizardViewController alloc] initWithNibName:@"WizardViewController" bundle:nil];
mj.countryselected = [countryNames objectAtIndex:indexPath.row];
[mj.countryButton setTitle:mj.countryselected forState:UIControlStateNormal];
[self dismissPopupViewControllerWithanimationType:MJPopupViewAnimationFade];
}
DetailViewController
is dismissing, but countryButtonTitle
is not updating. DetailViewController
正在关闭,但是countryButtonTitle
没有更新。 I know this is because the wizardview is not refreshing. 我知道这是因为WizardView没有刷新。 I would like to know the correct workaround in this case.
在这种情况下,我想知道正确的解决方法。
Hope this helps to get better answer. 希望这有助于获得更好的答案。
Make Protocol in MJDetailViewController
在
MJDetailViewController
制作协议
@protocol MJDetailViewControllerDelegate;
@interface MJDetailViewController : UIViewController
@property (nonatomic,assign) id< MJDetailViewControllerDelegate> delegate;
@end
@protocol MJDetailViewControllerDelegate <NSObject>
- (void)selectedContry:(NSString *)title;
@end
And call like 然后打电话
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath: (NSIndexPath *)indexPath {
NSString *title = [countryNames objectAtIndex:indexPath.row];
if ([self.delegate respondsToSelector:@selector(selectedContry:)]) {
[self.delegate selectedContry:title];
}
[self dismissPopupViewControllerWithanimationType:MJPopupViewAnimationFade];
}
Add MJDetailViewControllerDelegate
as a protocol
in WizardViewController.h
) 添加
MJDetailViewControllerDelegate
作为protocol
中WizardViewController.h
)
Now implement selectedContry:
method in WizardViewController.m
like: 现在在
WizardViewController.m
实现selectedContry:
方法, WizardViewController.m
所示:
- (void)selectedContry:(NSString *)title
{
[self.countryButton setTitle:title forState:UIControlStateNormal];
}
Hope it helps you. 希望对您有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.