This is what exactly I'm trying to do.
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. I know this is because the wizardview is not refreshing. I would like to know the correct workaround in this case.
Hope this helps to get better answer.
Make Protocol in 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
)
Now implement selectedContry:
method in WizardViewController.m
like:
- (void)selectedContry:(NSString *)title
{
[self.countryButton setTitle:title forState:UIControlStateNormal];
}
Hope it helps you.