4

Xcodeを更新しましたが、ストーリーボードでセレクターに接続されているすべてのボタンが突然機能しなくなりました。プログラムでコード化されたすべてのボタンとジェスチャ認識機能が機能します。部分的に、彼らは同じIBActionsを呼び出しています。

私が何をした...

ストーリーボードのビューにボタンとラベルを追加するだけです。View Controller .hで、ラベルにアウトレットを追加し、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{
    myLabel.text=@"Button is Running";
}
-(IBAction)swipe_active:(id)sender{
    myLabel.text=@"Swipe is Running";
}

@end

そして、ボタンだけでは機能しません。

ストーリーボード: https://i.stack.imgur.com/1hruM.png

4

2 に答える 2

3

xcode 4.5にアップグレードした後、これとまったく同じ問題が発生しました。IBActionは、IBで正しく設定されているように見えますが、.hファイルと.mファイルを見ると、そうではないことがわかります。ストーリーボードに移動してViewControllerをクリックすると、アウトレットの下を見ると、[ReceivedActions]のタブが表示されます。コントロールをそこでのアクションに接続すると、再び機能します。

于 2012-09-22T04:42:06.610 に答える
1

多くのアプリでまったく同じ問題が発生しています。私の場合はすべて、InterfaceBuilderでアクションを再接続することで修正されました。

于 2012-09-28T20:43:11.667 に答える