-1
-(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」 我設置一個的NSString變量名是 「數據」 我當我按下該按鈕時,想要在方法「showMessage」中獲取(在那裏打印)其值(YES U PRESSED BUTTON)。
我知道這是使用@選擇變量做..但我不知道它是怎麼做的