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. And yet alertView tag 开发者_运维问答8 is working fine.
Be careful, it should be == in your if statements. Apart from that, how do you assign tags to the alertviews?
精彩评论