我更新了我的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
試圖重新連接IB中的目標行爲?在我看來,這個問題是關於界面生成器(從代碼製作UI的另一個原因...) – 2012-09-21 10:55:36
錯誤後,我做了一個新的項目...同樣的問題 – BJS