简体   繁体   English

为什么此alertView代码不起作用? 没有错误,只是没有做应该做的

[英]Why is this alertView code not working? No error, just not doing as it should

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    NSLog(@"buttonindex: %i", buttonIndex);
    NSLog(@"tag: %i", alertView.tag);
    if ((alertView.tag <= 3) && (alertView.tag >= 1)) {

    } //Between 1 and 3
    else if (alertView.tag = 8) {

        }
    else if (alertView.tag = 10) {
        NSLog(@"Test");

    }
}

For some reason, even though i'm using alertView with tag 10, and it's returning "Tag: 10" on the NSLog, it isn't showing the "Test" log, or processing any code from within those last brackets. 出于某种原因,即使我使用带有标签10的alertView,并且在NSLog上返回“标签:10”,也没有显示“测试”日志,也没有处理最后括号中的任何代码。 And yet alertView tag 8 is working fine. 但是alertView标签8正常工作。

Be careful, it should be == in your if statements. 小心,在if语句中应为==。 Apart from that, how do you assign tags to the alertviews? 除此之外,如何将标签分配给Alertviews?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM