2012-09-21 70 views
4

我更新了我的Xcode,並且突然間所有在故事板中連接到選擇器的按鈕都不起作用了。所有編程編碼的按鈕和手勢識別器都可以工作。部分,他們正在調用相同的IBActions。XCode更新到版本4.5後按鈕不起作用

我做了什麼......

只需添加一個按鈕和一個標籤在故事板視圖。在視圖控制器中,我添加了一個Outlet到標籤並聲明瞭IBAction。 文件:

.H

#import <UIKit/UIKit.h> 

@interface ViewController : UIViewController 
@property (strong, nonatomic) IBOutlet UILabel *myLabel; 

-(IBAction)button_pressed:(id)sender; 
-(IBAction)swipe_active:(id)sender; 

@end 

.M

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 
@synthesize myLabel; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
    UISwipeGestureRecognizer *swipe_left = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipe_active:)]; 
    swipe_left.direction = UISwipeGestureRecognizerDirectionLeft; 
    [self.view addGestureRecognizer:swipe_left]; 

} 

-(IBAction)button_pressed:(id)sender{ 
    [email protected]"Button is Running"; 
} 
-(IBAction)swipe_active:(id)sender{ 
    [email protected]"Swipe is Running"; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

@end 

而只是按鈕不起作用。

故事板:http://i.stack.imgur.com/1hruM.png

+3

試圖重新連接IB中的目標行爲?在我看來,這個問題是關於界面生成器(從代碼製作UI的另一個原因...) – 2012-09-21 10:55:36

+2

錯誤後,我做了一個新的項目...同樣的問題 – BJS

回答

3

我升級到4.5的Xcode後有同樣的確切問題。 IBActions看起來好像是在IB中正確設置的,但如果您查看.h和.m文件,則會看到它們不是。如果您轉到故事板並單擊視圖控制器,請查看插座下面的內容,然後您會看到「已收到的操作」選項卡。把你的控制連接到你的行動,他們會再次工作。

+0

當IBActions被繼承爲如何解決這個問題他們沒有直接顯示在.h中? –

1

我已經看到了許多應用程序的完全相同的問題。在我所有的情況下,它都是通過重新連接Interface Builder中的動作來解決的。