问题
I've been staring at this for way too long.
There's nothing fancy happening here, and I've done this dozens of times, yet Interface Builder steadfastly refuses to provide me an action target for -(IBAction)slideDirections
. I'm at the point where I'm willing to post publicly and feel stupid. So let 'er rip.
Here's my .h:
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
@interface PulseDetailController : UIViewController {
NSDictionary *pulse;
IBOutlet MKMapView *map;
IBOutlet UIWebView *directions;
IBOutlet UIView *directionsSlider;
BOOL directionsExtended;
IBOutlet UILabel *vendor;
IBOutlet UILabel *offer;
IBOutlet UILabel *offerText;
IBOutlet UILabel *hours;
IBOutlet UILabel *minutes;
IBOutlet UILabel *seconds;
IBOutlet UILabel *distance
}
@property (nonatomic, retain) NSDictionary *pulse;
@property (nonatomic, retain) MKMapView *map;
@property (nonatomic, retain) UIWebView *directions;
@property (nonatomic, retain) UIView *directionsSlider;
@property (nonatomic) BOOL directionsExtended;
@property (nonatomic, retain) UILabel *vendor;
@property (nonatomic, retain) UILabel *offer;
@property (nonatomic, retain) UILabel *offerText;
@property (nonatomic, retain) UILabel *hours;
@property (nonatomic, retain) UILabel *minutes;
@property (nonatomic, retain) UILabel *seconds;
@property (nonatomic, retain) UILabel *distance;
-(IBAction)slideDirections;
@end
回答1:
Sometimes Interface Builder seems to get out of sync with classes in Xcode. Have you tried forcing interface builder to reread your PulseDetailController header file? (File -> Read Class Files... -> Select 'PulseDetailController.h'
). This should force Interface Builder to see your new action.
回答2:
Shouldn't the IBAction
have a sender parameter?
Like:
-(IBAction)slideDirections:(id)sender;
回答3:
Which objects are you trying to connect?
From your header, the logical choice would be UIView *directionsSlider
If you are ctrl dragging from directionsSlider
to the "File's Owner" object, make sure that the Class in "File's Owner" is set to PulseDetailController
.
来源:https://stackoverflow.com/questions/3008287/why-doesnt-ib-see-my-ibaction