2012-09-26 50 views
0

當我即時通訊相當新的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. 
     } 
} 
+0

當你說「萊夫特賽德或分段的控制對象的rightside」你的聲音,彷彿仍有超過實際使用什麼樣的UI對象(S)的混淆。我以爲你會改變開關。 –

+0

基本上,下面的教程,我拖着從庫分段控制,但是從UISegmentedControl變型使得出口連接 – DanKiiing

+0

我不知道這本書的時候UISwtich但你必須是一致的。如果您使用分段控件,則必須以這種方式聲明它們,並只調用其方法。如果你想使用開關方法/邏輯,那麼你必須有匹配的UI元素。如果一個從另一個繼承,但它們不相同則會不同。 –

回答

1

一個UISwitchsetOn:animated:方法自動進行,但一個UISegmentedControl沒有。我猜你指定的對象leftSwitchrightSwitch這是不是你想要的那種(或預期的教程)。

+0

我改變了UISegmentedControl到UISwitch,一切工作正常,直到我在leftswtich點擊並獲得「信號SIGABRT」錯誤-_- – DanKiiing

+0

好了,我們已經轉移到下一個錯誤..這是編程。 :-)你需要在錯誤發生時提供關於堆棧的一些細節,也許需要在開關激活時執行的代碼。 –

+0

當我點擊分段控制對象的左鍵時,程序會自動在頭部代理代碼上創建一個斷點。這就是我的意思。我已經在我原來的問題中包含了這段代碼。 – DanKiiing