Re: [問題] NSString 帶入判斷式
打開Interface Builder
在你的Button的Button Attributes裡.
將Tag的值設成 1000~1xxxx (可任意)
然後在你的method裡寫
if(![sender isKindOfClass:[NSButton class]]){
return;
}
int buttontag = [sender tag];
switch (buttontag){
case 1000: // button 1000 has been pressed.
break;
case 1001: // button 1001 has been pressed.
break;
.
.
}
※ 引述《love100205mt (石炭石炭)》之銘言:
: 各位高手!!請幫幫小弟
: 我利用了
: NSString *title= [sender titleForState:UIControlStateNormal];
: 抓到了我這個button的title
: 可是把title帶入if判斷式內的時候
: 一直判斷錯誤
: 以下我的寫法
: 總共有四個按鈕其中一個的title是1
: if (title !="1") {
: UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"正確"
: message:@"接下去"
: delegate:self
: cancelButtonTitle:@"確定"
: otherButtonTitles:nil];
: [alert show];
: [alert release];
: }
: 總共有四個按鈕其中一個的title是1
: 結果四個按鈕都會跳出正確這個視窗
: 因為到這一步都無法正確所以沒有寫下面的
: 請各位高手幫我解答一下!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 203.69.87.123
推
03/08 15:13, , 1F
03/08 15:13, 1F
推
03/08 15:15, , 2F
03/08 15:15, 2F
→
03/08 15:16, , 3F
03/08 15:16, 3F
推
03/08 15:16, , 4F
03/08 15:16, 4F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 2 篇):