可能性の重複:方法で上記のコードで
Uibutton eventsuibuttonイベント
-(void)myButtonclick {
NSString *data=[[NSString alloc]initWithString:@"YES U PRESSED BUTTON"];
UIButton *refreshbutton=[UIButton buttonWithType:UIButtonTypeCustom];
[refreshbutton setFrame:CGRectMake(15.0f, 330.0f, 150.0f, 32.0f)];
[refreshbutton setCenter:CGPointMake(80.0f,340)];
[refreshbutton setBackgroundImage: normalImage forState: UIControlStateNormal];
[refreshbutton setBackgroundImage: downImage forState: UIControlStateHighlighted];
[refreshbutton setBackgroundImage: selectedImage forState: UIControlStateSelected];
[refreshbutton setTitle:@"Refresh" forState:UIControlStateNormal];
[refreshbutton addTarget:self action:@selector(showMessage:) forControlEvents:UIControlEventTouchUpInside];
}
-(id)showMessage:(id)sender{
// Here I want to get the value of "data" which is defined the method
// "myButtonclick" in the first line. how it is possible..?
}
"myButtonclick" 私が設定された1人のNSStringの変数名は "データ" Iでありますそのボタンを押したときにメソッド "showMessage"にその値(YES U PRESSED BUTTON)を取得(そこに表示)したいと思います。
私はこれが@selector変数を使用して行われている知っている..しかし、私はそれが