我有一个应用程序,问你一个问题(这个形状有多少边)然后我声明一个uitextfield并称之为txt,如果你在uitextfield中写了8并按完了,你应该去下一个问题因为8是正确的,这是我的if语句代码:
if (txt.text == @"8") {
[self q7done];
} else {
Fail *fail = [[Fail alloc]
initWithNibName:@"Fail" bundle:nil];
fail.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:fail animated:YES];
}
好!当我输入8时,它会进入失败页面。糟透了,我不知道为什么???我甚至尝试将uitextfield的文本设置为0.02 alpha的标签,如果LABELS文本为8,则将if语句更改为blah blah blah,help pls。
答案 0 :(得分:4)
if ([txt.text isEqualToString:@"8"]) {
....
答案 1 :(得分:0)
NSString *string1 = yourtextfield.text;
NSString *string2= @"8";
if ([string1 isEqualToString:string2]) { //compare here.
[self q7done];
} else {
Fail *fail = [[Fail alloc]
initWithNibName:@"Fail" bundle:nil];
fail.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:fail animated:YES];
}