看板 MacDev 關於我們 聯絡資訊
抱歉我又來發問了(汗) 1. 我要設定一個防呆 防呆的內容是當每一個radio button都沒有按到時 會跳出警告視窗而且next page這個按鈕就不會出現(預設值就是hidden) 程式碼如下: if ([radiobutton1 isSelected]==NO) { if ([radiobutton2 isSelected]==NO) { if ([radiobutton3 isSelected]==NO) { if ([radiobutton4 isSelected]==NO) { if ([radiobutton5 isSelected]==NO) { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You do not choose radio button,it's nessary" message:@"Please choose one at least" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; NextPage.hidden=YES; } } } } } NextPage.hidden=NO; 每次一按下去雖然會跳出警告視窗 可是next page的按鈕也會出現 這樣就跟沒有防呆一樣了(next page是用seguse) 該怎麼解決呢? 2. 我需要讀label裡面的值 然後丟到演算法去對應出一個值 int PostureScoreA; float LocateUpperArm=[[LocateUpperArmInWristTwist text]intValue]; float LocateLowerArm=[[LocateLowerArmInWristTwist text]intValue]; float LocateWrist=[[LocateWristInWristTwist text]intValue]; float WristTwist=[[WristTwistResult text]intValue]; //範例演算法 if (LocateUpperArm==1) { if (LocateLowerArm==1) { if (LocateWrist==1) { if (WristTwist==1) { PostureScoreA=1; } } } } //(1,1,1,1) PostureA.text = [NSString stringWithFormat:@"%.f",(PostureScoreA)]; 可是每次執行都會斷在LocateUpperArm這一行 請問原因在哪裡? 以上兩個問題 謝謝大家~ -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.114.54.99 ※ 文章網址: http://www.ptt.cc/bbs/MacDev/M.1413104948.A.079.html
stweber2001: 1. 最裡面那層加上 else 10/12 19:31
stweber2001: 2. 因為不等於1? 光是看敘述無法了解問題 10/12 19:33
ljuyentintho: 1裡面要放 else{NextPage.hidden=NO;}這樣嗎?可是 10/12 20:00
ljuyentintho: 這樣連按了以後都無法顯示出nextpage的按鈕了 10/12 20:02
atst2: 1.照你目前的寫法,每一層都要加else 10/12 20:09
atst2: 最好改成用一個變數來記要不要hidden,然後不要在這裡判斷 10/12 20:10
atst2: 然後每次radiobuttonX動作時,應該會觸發action,在action中 10/12 20:11
atst2: 直接去設定hidden。 10/12 20:12
atst2: if else 太多層後續不好維護 10/12 20:12
TarHeel: 用 Outlet Collection, 然後 loop array, 只要1個沒就NO 10/19 19:12