我創建一個按鈕並將標題設置爲「單擊此處」。當我按下那個按鈕時,我想獲得那個按鈕標題並記錄下來。這是我的代碼,我哪裏錯了?在事件處理程序中獲取UIButton的標題
-(void)clicketbutton {
UIButton *mybutton = [UIButton buttonWithType:UIButtonTypeCustom];
[mybutton setTitle:@"Click here" forState:UIControlStateNormal];
[mybutton addTarget:self
action:@selector(displayvalue:)forControlEvents:UIControlEventTouchUpInside];
}
-(void)displayvalue:(id)sender {
UIButton *resultebutton= [UIButton buttonWithType:UIButtonTypeCustom];
resultebutton=sender;// pls clear here.. my question here , it it possible or not. if possible how ?
NSLog(@" The buttontitile is %@ ", [resultebutton.Title] // here also.
}
很好的歡呼聲 – 2011-04-15 08:31:10