MacDev 板


LINE

1. 个人很讨厌一堆if一层一层的下去,所以大多都这样做 NSArray *buttonsArray = [NSArray arrayWithObjects:radiobutton1, radiobutton2, radiobutton3, radiobutton4, radiobutton5]; bool noButtonIsSelected = NO; for (UIButton *tempButton in buttonsArray){ if(tempButton.isSelected == YES){ noButtonIsSelected = YES; break; } } if (noButtonIsSelected){ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TITLE" message:@"message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; NextPage.hidden = YES; }else{ NextPage.hidden = NO } 2. 这问题应该很简单... 就是你干嘛宣告 float 但是里面塞的值是int呀~ 看你的label.text有没有可能是小数点的 有就把他转成floatValue 不然就一律转int吧 ※ 引述《ljuyentintho (小刘)》之铭言: : 抱歉我又来发问了(汗) : 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), 来自: 220.132.180.49
※ 文章网址: http://webptt.com/cn.aspx?n=bbs/MacDev/M.1413116197.A.4C7.html
1F:推 darktt: 第一项其实也可以这样子做 10/12 21:58
2F:→ darktt: bool buttonSelect = No; 10/12 21:59
3F:→ darktt: buttonSelect |= radiobutton1.select 10/12 21:59
4F:→ darktt: buttonSelect |= radiobutton2.select 10/12 22:00
5F:→ darktt: 这样子下去,最後再判断buttonSelect是不是Yes就好了 10/12 22:00
可以呀~ 只是我习惯用这方法因为你在for里面可以判定很多东西 所以就习惯了~ ※ 编辑: tentenlee (220.132.180.49), 10/12/2014 22:37:22
6F:推 howdiun: 把它模组化的话就只能用回圈了 10/13 09:23







like.gif 您可能会有兴趣的文章
icon.png[问题/行为] 猫晚上进房间会不会有憋尿问题
icon.pngRe: [闲聊] 选了错误的女孩成为魔法少女 XDDDDDDDDDD
icon.png[正妹] 瑞典 一张
icon.png[心得] EMS高领长版毛衣.墨小楼MC1002
icon.png[分享] 丹龙隔热纸GE55+33+22
icon.png[问题] 清洗洗衣机
icon.png[寻物] 窗台下的空间
icon.png[闲聊] 双极の女神1 木魔爵
icon.png[售车] 新竹 1997 march 1297cc 白色 四门
icon.png[讨论] 能从照片感受到摄影者心情吗
icon.png[狂贺] 贺贺贺贺 贺!岛村卯月!总选举NO.1
icon.png[难过] 羡慕白皮肤的女生
icon.png阅读文章
icon.png[黑特]
icon.png[问题] SBK S1安装於安全帽位置
icon.png[分享] 旧woo100绝版开箱!!
icon.pngRe: [无言] 关於小包卫生纸
icon.png[开箱] E5-2683V3 RX480Strix 快睿C1 简单测试
icon.png[心得] 苍の海贼龙 地狱 执行者16PT
icon.png[售车] 1999年Virage iO 1.8EXi
icon.png[心得] 挑战33 LV10 狮子座pt solo
icon.png[闲聊] 手把手教你不被桶之新手主购教学
icon.png[分享] Civic Type R 量产版官方照无预警流出
icon.png[售车] Golf 4 2.0 银色 自排
icon.png[出售] Graco提篮汽座(有底座)2000元诚可议
icon.png[问题] 请问补牙材质掉了还能再补吗?(台中半年内
icon.png[问题] 44th 单曲 生写竟然都给重复的啊啊!
icon.png[心得] 华南红卡/icash 核卡
icon.png[问题] 拔牙矫正这样正常吗
icon.png[赠送] 老莫高业 初业 102年版
icon.png[情报] 三大行动支付 本季掀战火
icon.png[宝宝] 博客来Amos水蜡笔5/1特价五折
icon.pngRe: [心得] 新鲜人一些面试分享
icon.png[心得] 苍の海贼龙 地狱 麒麟25PT
icon.pngRe: [闲聊] (君の名は。雷慎入) 君名二创漫画翻译
icon.pngRe: [闲聊] OGN中场影片:失踪人口局 (英文字幕)
icon.png[问题] 台湾大哥大4G讯号差
icon.png[出售] [全国]全新千寻侘草LED灯, 水草

请输入看板名称,例如:Soft_Job站内搜寻

TOP