我想用这个空位
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@"One point,Not good"])
{
} 连接到mysql并更新名为scores的列中的值。
例如
在开始的列中有五个点,然后我按下警报查看按钮“一点”
则值列将更改为六个点。
我不知道如何使用这个空格来做这件事,我已经搜索了很多信息,但我没有得到它
我使用json和php连接到mysql,我使用phpmyadmin。
不管我做错了,还是这个空洞都用在这上面了。
发布于 2012-10-01 20:47:06
首先设置UIAlertview的标记值,然后
您应该使用按钮索引值,而不是它的字符串文本
//我刚刚把标签值取为204
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(alertView.tag==204 && buttonIndex==1)
{
//your logic
}
else if(alertView.tag==204 && buttonIndex==0)
{
//your logic
}
}发布于 2012-10-01 20:42:49
使用按钮索引
if(buttonIndex == 1)
{
// write the logic here
return;
}
else if(buttonIndex == 2)
{
// write the logic here
return;
}发布于 2012-10-01 20:47:20
您必须使用的函数如下
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex;要使用此函数,您的ViewController必须实现UIAlertViewDelegate
在.h yourViewController : UIViewController <UIAlertViewDelegate>中
示例
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
if(buttonIndex == 0)
{
//do something if you press the "cancel" button
} else if (buttonIndex == 1) {
//do other thing with other button
}
}https://stackoverflow.com/questions/12673359
复制相似问题