當我即時通訊相當新的iOS開發,並按照教程練習上我遇到了一些書「開頭的iOS5發展」的第四章對我的代碼編譯錯誤。申報界面錯誤建設項目
這裏就是我標題代碼的.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所面臨的錯誤「爲‘UISegmentedControl’不可見的@interface聲明選擇‘西頓:動畫;’
@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 ......這裏就是我儘快談,因爲我在分段控制對象的萊夫特賽德或rightside點擊斷點在我的授權頭代碼在這裏
#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.
}
}
當你說「萊夫特賽德或分段的控制對象的rightside」你的聲音,彷彿仍有超過實際使用什麼樣的UI對象(S)的混淆。我以爲你會改變開關。 –
基本上,下面的教程,我拖着從庫分段控制,但是從UISegmentedControl變型使得出口連接 – DanKiiing
我不知道這本書的時候UISwtich但你必須是一致的。如果您使用分段控件,則必須以這種方式聲明它們,並只調用其方法。如果你想使用開關方法/邏輯,那麼你必須有匹配的UI元素。如果一個從另一個繼承,但它們不相同則會不同。 –