0

ボタンのようなクリック可能なオブジェクトを作成する必要があります。グラフィックは、テキストが中央にある長方形である必要があります。四角形は、ボタンのようにクリック可能にする必要があります。整数を保持できるように、角に 4 つのラベルが必要です。これらの「ラベル」をクリックすると、ボタンのように別のアクションを実行する必要があります。

いったいどうやってこれから始めるべきですか?

4

1 に答える 1

1

5 つのボタンを持つ UIView サブクラスを作成します (タップできる場合は、ラベルではなくボタンにする必要があります)。

@property (nonatomic, weak) IBOutlet UIButton *middleButton;
@property (nonatomic, weak) IBOutlet UIButton *topLeftButton;
@property (nonatomic, weak) IBOutlet UIButton *topRightButton;
@property (nonatomic, weak) IBOutlet UIButton *bottomLeftButton;
@property (nonatomic, weak) IBOutlet UIButton *bottomRightButton;

また、ボタンがタップされたことを伝えるために IBAction を接続する必要があります。

[self.middleButton addTarget:self action:@selector(middleButtonTapped) forControlEvents:UIControlEventTouchUpInside];

- (void)middleButtonTapped
{
    //This method is called when the middle button is tapped
}

IBAction を作成して、ストーリーボード/xib にボタンを接続することもできます。

- (IBAction)middleButtonTapped
{

    //This method is called when the middle button is tapped
}
于 2013-10-19T21:25:45.767 に答える