我有一个视图控制器,它有一个动作来呈现视图cotroller
GoodNewsBodyViewController.h
@interface GoodNewsBodyViewController : UIViewController<EventListDelegate>
GoodNewsBodyViewController.m
-(IBAction)goToEvents:(id)sender {
EventTableViewController* eventsController = [[EventTableViewController alloc] initWithNibName:@"EventTableViewController" bundle:nil];
[eventsController setListOfEvents:goodNews.Events];
//try both ways
[eventsController setDelegate:self];
eventsController.delegate = self;
[self presentModalViewController:eventsController animated:YES];
}
- (void)loginFormDidFinish:(EventTableViewController*)loginForm {
// do whatever, then
// hide the modal view
EventViewController *eventController = [[EventViewController alloc] initWithNibName:@"EventViewController" bundle:nil];
[eventController setEvent:loginForm.event];
[self.navigationController pushViewController:eventController animated:YES];
// clean up
[self dismissModalViewControllerAnimated:YES];
}
EventTableViewController.h
@class EventTableViewController;
@protocol EventListDelegate
- (void)loginFormDidFinish:(EventTableViewController*)loginForm;
@end
@interface EventTableViewController : UIViewController <RKObjectLoaderDelegate, UITableViewDataSource, UITableViewDelegate> {
id<EventListDelegate> delegate;
NSArray* eventList;
Organisation* organisation;
IBOutlet UITableView* _tableView;
NSMutableArray* listOfEvents;
Event* event;
}
@property (strong) id<EventListDelegate> delegate;
@property (nonatomic, strong) IBOutlet UITableView* _tableView;
@property (nonatomic, strong) NSArray* eventList;
@property (nonatomic, strong) Organisation* organisation;
@property (nonatomic, strong) NSMutableArray* listOfEvents;
@property (nonatomic, strong) Event* event;
当在eventstableviewcontroller中选择了一个事件时,我想要回发该事件。我试图通过将事件作为在eventstableviewcontroller的didselect方法中设置的属性来实现。正在显示事件列表,当选择事件时,列表会消失。这一切都是正确的,但是 - (void)loginFormDidFinish:(EventTableViewController *)loginForm;
事件似乎没有开火,我已经设置了断点,但他们从未被击中......任何帮助都表示赞赏!
答案 0 :(得分:0)
您的loginFormDidFinish:
方法应该是这样的
-
(void)loginFormDidFinish:(EventTableViewController*)loginForm {
// hide the modal view
[self dismissModalViewControllerAnimated:NO];//without animation
EventViewController *eventController = [[EventViewController alloc] initWithNibName:@"EventViewController" bundle:nil];
[eventController setEvent:loginForm.event];
[self.navigationController pushViewController:eventController animated:YES];
[eventController release];
// clean up
}