如果用户取消alertview
,我尝试显示某些文字时alertivew
出现问题。
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset
{
UIALertView alertview = [[UIAlertView alloc] initWithTitle:@"New Answer"
message:@"Your text"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[alert show]
if (buttonIndex == 0)
{
NSLog(@"ok");
[[self sectionSelectedDisplay] setText:answerLabel];
}
else
{
NSLog(@"cancel");
}
}
+++++++++++++++++++++++++
任何人都可以帮我解决这个问题吗?
答案 0 :(得分:1)
UIalertviewdelegate中有一个函数
如果您有两个按钮,则功能如下
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 1) {
// this is normal button
}
else if (buttonIndex == 0) {
// this is cancel button
}
}