質問

I am trying to incorporate TSPopover into my iPad app (XCode 4.6, Storyboards with UITabBarController, iOS 6.2). I have copied the TSPopover code into my app, and picked one controller to start with. On one scene, I have the little 'i' in a circle for the user to tap when they need help (it's going to eventually be localized, thus the need for the help). So, I have this code in -viewDidLoad:

    if(tfShopOpens.text.length == 0 || shopCloses.text.length == 0)  {
/*  (below code copied from the TSPopover demo code)
 UIButton *topButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];

 [topButton addTarget:self action:@selector(showPopover:forEvent:) forControlEvents:UIControlEventTouchUpInside];

 topButton.frame = CGRectMake(10,10, 300, 30);
 [topButton setTitle:@"button" forState:UIControlStateNormal];
 topButton.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
 [self.view addSubview:topButton];
 */

 [boHelpStoreHours addTarget:self action:@selector(showPopover:forEvent:) forControlEvents:UIControlEventTouchUpInside];

This is from the .h file:

- (IBAction)bHelpStoreHours:(UIButton *)sender;
@property (strong, nonatomic) IBOutlet UIButton *boHelpStoreHours;

This is from the Connections Inspector:

enter image description here

This is the error I'm getting when I tap this particular button:

2013-04-02 15:49:48.016 saori[5495:c07] -[PreferencesViewController bHelpStoreHours:]: unrecognized selector sent to instance 0x8a6c510 2013-04-02 15:49:48.019 saori[5495:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[PreferencesViewController bHelpStoreHours:]: unrecognized selector sent to instance 0x8a6c510' * First throw call stack: (0x26fc012 0x19eae7e 0x27874bd 0x26ebbbc 0x26eb94e 0x19fe705 0x9322c0 0x932258 0x9f3021 0x9f357f 0x9f26e8 0x961cef 0x961f02 0x93fd4a 0x931698 0x2b79df9 0x2b79ad0 0x2671bf5 0x2671962 0x26a2bb6 0x26a1f44 0x26a1e1b 0x2b787e3 0x2b78668 0x92effc 0x222d 0x2155 0x1) libc++abi.dylib: terminate called throwing an exception

The problem I'm having is that I'm not sure everything is connected correctly to make this work. There are NO comments in the TSPopover code to guide me, so I'm guessing what is needed. I have looked in Google and SO... nothing! What is causing the run-time crash? and how do I fix it?

役に立ちましたか?

解決

Your bHelpStoresHours: method may not exist in your @implementation. Make sure you have defined the method in your PreferencesViewController.m file.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top