我对ios开发相当新,并且按照“开始ios5开发”一书的第4章的教程练习,我的代码遇到了一些编译错误。
这是我的标题代码.h文件的样子
#import <UIKit/UIKit.h>
@interface BIDViewController : UIViewController
@property (strong, nonatomic) IBOutlet UITextField *namefIELD;
@property (strong, nonatomic) IBOutlet UITextField *numberField;
@property (strong, nonatomic) IBOutlet UILabel *sliderLabel;
@property (strong, nonatomic) IBOutlet UISegmentedControl *leftSwitch;
@property (strong, nonatomic) IBOutlet UISegmentedControl *rightSwitch;
@property (strong, nonatomic) IBOutlet UIButton *doSomethingButton;
-(IBAction)textFieldDoneEditing:(id)sender;
//to initialize the 'done' button when editing to confirm you have finished editing/
-(IBAction) backgroundTap:(id)sender;
- (IBAction)sliderChanged:(id)sender;
- (IBAction)switchChanged:(id)sender;
- (IBAction)toggleControls:(id)sender;
- (IBAction)buttonPressed:(id)sender;
@end
这里是我的.m代码,其中im面临错误“没有可见@interface for'UISegmentedControl'声明了选择器'setOn:animated;'
@synthesize leftSwitch;
@synthesize rightSwitch;
- (IBAction)switchChanged:(id)sender {
UISwitch *whichSwitch = (UISwitch *)sender;
BOOL setting = whichSwitch.isOn;
[leftSwitch setOn: setting animated: YES]; //the error lies here/
[rightSwitch setO: setting animated: YES]; //the error lies here/
}
- (IBAction)toggleControls:(id)sender {
}
- (IBAction)buttonPressed:(id)sender {
}
@end
错误语句是“没有可见的@interface for'UISegmentedControl”声明了选择器'setOn:animated;'
请帮助,这将受到高度赞赏和投票:)
@PhilipMills ...这就是我所说的,只要点击分段控制对象的左侧或右侧,我的委托标题代码就会自动产生断点
#import <UIKit/UIKit.h>
#import "BIDAppDelegate.h"
int main(int argc, char *argv[])
{
@autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([BIDAppDelegate class])); //the breakpoint appears here.
}
}
答案 0 :(得分:1)
UISwitch
有一个setOn:animated:
方法,但UISegmentedControl
没有。我猜您已将对象分配给leftSwitch
和rightSwitch
,这些对象不是您想要的那种(或教程的目的)。