私はiOSプログラミングが初めてで、この単純な概念を機能させることができません.ポップアップコントローラーがメソッドを呼び出して親コントローラーでデータを送信できるようにしたいだけです. ここで私が間違っていることを誰かが見つけることができますか?
DetailViewController.h で
#import <UIKit/UIKit.h>
#import "Employee.h"
#import "CompleteViewController.h"
@class EmployeesTVC;
@interface DetailViewController : UIViewController <UISplitViewControllerDelegate, UIPopoverControllerDelegate>
@property (strong) UIPopoverController *popController;
-(IBAction)completeButtonPressed:(id)sender;
@end
in DetailViewController.m (無関係な部分を取り出した)
@implementation DetailViewController {
__weak UIPopoverController *completePopover;
}
// ...
#pragma mark - Complete / Score popover methods
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"preparing for segue");
UIStoryboardPopoverSegue *popoverSegue = (UIStoryboardPopoverSegue *)segue;
UIPopoverController *scorePopoverController = [popoverSegue popoverController];
[scorePopoverController setDelegate:self];
self.popController = scorePopoverController;
}
- (IBAction)completeButtonPressed:(id)sender {
if (completePopover) {
[completePopover dismissPopoverAnimated:YES];
} else {
[self performSegueWithIdentifier:@"showScorePopover" sender:sender];
}
}
- (void) scoreAssigned:(NSString *)score {
NSLog(score);
NSLog(@"Score Assigned");
}
// ...
@end
CompleteViewController.h (ポップアップ ビュー コントローラー)
#import <UIKit/UIKit.h>
@protocol CompleteViewDelegate <NSObject>
- (void)scoreAssigned:(NSString *)score;
@end
@interface CompleteViewController : UIViewController
@property (nonatomic, assign) id<CompleteViewDelegate> delegate;
- (IBAction)okButtonPressed:(id)sender;
@end
CompleteViewController.m
#import "CompleteViewController.h"
@implementation CompleteViewController
@synthesize delegate;
- (IBAction)okButtonPressed:(id)sender {
NSLog(@"OK Button Pressed");
[delegate scoreAssigned:@"100"];
}
@end