我有 UIButton 取消 tableviewcontroller 的问题,当我做测试时,我点击取消按钮来调用动作,他没有给代表打电话,没有工作,遵守代码。
StalkViewController
#import <UIKit/UIKit.h>
#import "FMDBDataAccess.h"
#import "EditStalkViewController.h"
#import "NewStalkViewController.h"
@interface StalkViewController : UITableViewController<NewStalkViewControllerDelegate>
@property (nonatomic,strong) NSMutableArray *stalks;
-(void)populateStalk;
@end
StalkViewController.m
-(void) addNewStalkViewControllerDidCancel:(NewStalkViewController *)controller
{
[self dismissViewControllerAnimated:YES completion:nil];
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([segue.identifier isEqualToString:@"addStalk"])
{
UINavigationController *navigationController = segue.destinationViewController;
NewStalkViewController *addNewStalkViewController = (NewStalkViewController *)[[navigationController viewControllers] objectAtIndex:0];
addNewStalkViewController.delegate = self;
}
}
NewStalkViewController.h
#import "Stalk.h"
#import "Utility.h"
@class NewStalkViewController;
@protocol NewStalkViewControllerDelegate<NSObject>
-(void) addNewStalkViewControllerDidCancel:(NewStalkViewController *)controller;
@end
@interface NewStalkViewController : UITableViewController<FBFriendPickerDelegate, UITextFieldDelegate>
{
}
@property (nonatomic,weak) id<NewStalkViewControllerDelegate> delegate;
- (IBAction)cancel:(id)sender;
@end
NewStalkViewController.m
#import "NewStalkViewController.h"
@implementation NewStalkViewController
@synthesize delegate;
-(IBAction)cancel:(id)sender
{
[self.delegate addNewStalkViewControllerDidCancel:self];
}
@end
帮助我!!