gpt4 book ai didi

iOS - UIAlertView outton - 其他按钮无法正常工作

转载 作者:行者123 更新时间:2023-11-29 04:09:29 26 4
gpt4 key购买 nike

我的应用程序遇到问题。问题是当我按下 AlertView 上的“取消”按钮时。它没有显示应该出现在我的输出中的“取消”文本。确认和显示密码按钮工作正常,都显示 NSLogs,只有取消按钮不显示。这是我的代码。请耐心等待我,因为我是 Xcode 新手。

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Confirm"])
{
UITextField *password = [alertView textFieldAtIndex:0];
NSLog(@"Password: %@", password.text);

if (buttonIndex != [alertView cancelButtonIndex])
{
NSLog(@"cancel");
}
else
{

NSLog(@"confirm");


entries = [[NSMutableArray alloc]init];
NSString *select = [NSString stringWithFormat:@"SELECT * FROM summary2 WHERE username = '%s' and pass = '%s'",[self.lbUser.text UTF8String],[password.text UTF8String]];
sqlite3_stmt *statement;
if (sqlite3_prepare(user, [select UTF8String], -1, &statement, nil)==SQLITE_OK)
{
if(sqlite3_step(statement)==SQLITE_ROW)
{
NSLog(@"database updated");
[self updatedatabase];
UIAlertView *alert3 = [[UIAlertView alloc]initWithTitle:@"Done" message:@"Account was updated successfully!" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert3 show];
}
else
{

NSLog(@"Authentication Failed!");
UIAlertView *alert2 = [[UIAlertView alloc]initWithTitle:@"Failed" message:@"Wrong Password! Account was not updated." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert2 show];


NSLog(@"fail");
}


}


}
}
else if([title isEqualToString:@"View Password"])
{
UITextField *password = [alertView textFieldAtIndex:0];
NSLog(@"Password: %@", password.text);

if (buttonIndex != [alertView cancelButtonIndex])
{
NSLog(@"cancel");
}
else
{

NSLog(@"confirm");


entries = [[NSMutableArray alloc]init];
NSString *select = [NSString stringWithFormat:@"SELECT * FROM summary2 WHERE username = '%s' and pass = '%s'",[self.lbUser.text UTF8String],[password.text UTF8String]];
sqlite3_stmt *statement;
if (sqlite3_prepare(user, [select UTF8String], -1, &statement, nil)==SQLITE_OK)
{
if(sqlite3_step(statement)==SQLITE_ROW)
{
NSLog(@"database updated");
[self switchbtn];

}
else
{
//switch1.on=YES;
NSLog(@"Authentication Failed!");
UIAlertView *alert2 = [[UIAlertView alloc]initWithTitle:@"Failed" message:@"Wrong Password! Cannot view password." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert2 show];


NSLog(@"fail");
}


}


}
}
}

最佳答案

根据您的 if,if-else 语句,您只是在寻找“查看密码”和“确认”按钮。 if 语句中没有分支来检查取消按钮。

关于iOS - UIAlertView outton - 其他按钮无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14640460/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com