0

我在视图控制器下面有两个按钮。其中一个按钮进行计算。第二个显示有关这些计算的信息。对于信息,我正在使用模态 segue 到另一个名为 werkwijzeViewController 的视图控制器。计算按钮不会造成问题。在按下信息按钮时,我得到“UIStoryboardModalSegue popoverController]:无法识别的选择器发送到实例”。怎么了?我正在上传一些相关代码:

视图控制器.h

#import <UIKit/UIKit.h>
#import "breuk.h"
#import "verklaringViewController.h"

@interface ViewController : UIViewController <UIPopoverControllerDelegate>
@property (strong, nonatomic) IBOutlet UITextField *tellerVeld1;
@property (strong, nonatomic) IBOutlet UITextField *noemerVeld1;
@property (strong, nonatomic) IBOutlet UILabel *quotientVeld;
@property (strong, nonatomic) IBOutlet UITextField *tellerVeld2;
@property (strong, nonatomic) IBOutlet UITextField *noemerVeld2;
@property (strong, nonatomic) IBOutlet UIButton *berekenKnop;
@property (strong, nonatomic) breuk *breuk1;
@property (strong, nonatomic) breuk *breuk2;
@property (strong, nonatomic) breuk *hoofdbreuk;

@property (strong, nonatomic) IBOutlet UITextField *uitkomstNoemerVeld;
@property (strong, nonatomic) IBOutlet UITextField *uitkomstTellerVeld;
@property (strong, nonatomic) IBOutlet UILabel *uitkomstStreep;

@property (strong, nonatomic) UIPopoverController *popoverController;



- (IBAction)berekenQuotient:(id)sender;
@end

视图控制器.m

#import "ViewController.h"

@interface ViewController ()
{


    BOOL veldVerplaatst;
}
@end

@implementation ViewController
@synthesize tellerVeld1;
@synthesize noemerVeld1;
@synthesize quotientVeld;
@synthesize tellerVeld2;
@synthesize noemerVeld2;
@synthesize berekenKnop;
@synthesize uitkomstNoemerVeld;
@synthesize uitkomstTellerVeld;
@synthesize uitkomstStreep;
@synthesize breuk1;
@synthesize breuk2;
@synthesize hoofdbreuk;
@synthesize popoverController;

...

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

   UIStoryboardPopoverSegue *popoverSegue;
   popoverSegue=(UIStoryboardPopoverSegue *)segue;

   UIPopoverController *popoverController;
   popoverController = popoverSegue.popoverController;
   popoverController.delegate = self;

   verklaringViewController *verklaringVC;
   verklaringVC=(verklaringViewController *)popoverController.contentViewController;

   ...
}

@结尾

werkwijzeViewController.h

#import <UIKit/UIKit.h>
#import "ViewController.h"

@interface werkwijzeViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIButton *af;
@property (strong, nonatomic) IBOutlet UITextView *vereenvoudigBreuken;
@property (strong, nonatomic) IBOutlet UITextView *vermenigvuldigBreuken;

@property (strong, nonatomic) NSMutableArray *tabelTellerOntbonden;
@property (strong, nonatomic) NSMutableArray *tabelNoemerOntbonden;
@property (strong, nonatomic) NSMutableArray *tabelGgdOntbonden;

@end

werkwijzeViewController.m

#import "werkwijzeViewController.h"

@interface werkwijzeViewController ()

@end

@implementation werkwijzeViewController
@synthesize tabelGgdOntbonden;
@synthesize tabelNoemerOntbonden;
@synthesize tabelTellerOntbonden;

...

- (void)viewDidLoad
{
    [super viewDidLoad];
// Do any additional setup after loading the view.
    tabelTellerOntbonden =[NSMutableArray new];
    tabelTellerOntbonden = [((ViewController *)self.presentingViewController).breuk1 ontbindInFactoren:((ViewController *)self.presentingViewController).breuk1.tellerBreuk inTabel:tabelTellerOntbonden];
    NSLog(@"%@",tabelTellerOntbonden);
}


@end

bruk.m

#import "breuk.h"

@implementation breuk
@synthesize tellerBreuk;
@synthesize noemerBreuk;
@synthesize origineleNoemerBreuk;
@synthesize origineleTellerBreuk;
@synthesize ggd;
@synthesize quotientBreuk;
 ...

   - (NSMutableArray *)ontbindInFactoren:(int)product inTabel:(NSMutableArray *)tabel
    {
        for (int priemfactor=1; priemfactor<=product; priemfactor++)
        {
            while (product%priemfactor==0)
            {
                [tabel addObject:[NSString stringWithFormat:@"%i",priemfactor]];
            }
        }
        return tabel;
    }


    @end
4

1 回答 1

1

您应该发布与您的两个按钮相关的所有 IBAction 方法的代码。

乍一看,在我看来问题在于您的 prepareForSegue 方法盲目地将您的 segue 转换为 UIStoryboardPopoverSegue,然后尝试访问 segue 的 popoverController 属性。

您的 prepareForSegue 方法将为每个 segue 调用。您需要在 prepareForSegue 中检查 segue 标识符的代码,以确保在将其转换为 UIStoryboardPopoverSegue 之前处理正确的 segue。

于 2013-10-28T17:38:02.283 回答