原问题来自于CSDN问答频道,更多解决方案见:http://ask.csdn.net/questions/1519原问题描述:
大家好,请教一个关于UIGestureRecognizer的问题。
比如我需要在用户在操作之后,用UIAlertView来确认提交动作,我试过一些方法都没成功。解决方案:
这样:
UISwipeGestureRecognizer *gesture1 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
gesture1.direction = UISwipeGestureRecognizerDirectionRight;
[yourView addGestureRecognizer:gesture1];
在Action方法中:
-(void)didSwipeLeft:(UIGestureRecognizer *)gestureRecognizer {
UIAlertView *Alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Are you sure to commit with its action" delegate:self cancelButtonTitle:CKString(@"NO") otherButtonTitles:CKString(@"YES"),nil];
[Alert show];
Alert.tag=222;
Alert.delegate=self;
[Alert release];
}
在AlertView Delegate
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if(alertView.tag==222) {
if(buttonIndex==1)
{
//// Yes condition
} else {
///// No condition
}
}
}ios
大家好,请教一个关于UIGestureRecognizer的问题。
比如我需要在用户在操作之后,用UIAlertView来确认提交动作,我试过一些方法都没成功。解决方案:
这样:
UISwipeGestureRecognizer *gesture1 = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(didSwipeRight:)];
gesture1.direction = UISwipeGestureRecognizerDirectionRight;
[yourView addGestureRecognizer:gesture1];
在Action方法中:
-(void)didSwipeLeft:(UIGestureRecognizer *)gestureRecognizer {
UIAlertView *Alert = [[UIAlertView alloc] initWithTitle:@"" message:@"Are you sure to commit with its action" delegate:self cancelButtonTitle:CKString(@"NO") otherButtonTitles:CKString(@"YES"),nil];
[Alert show];
Alert.tag=222;
Alert.delegate=self;
[Alert release];
}
在AlertView Delegate
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if(alertView.tag==222) {
if(buttonIndex==1)
{
//// Yes condition
} else {
///// No condition
}
}
}ios
解决方案 »
- 程序更新时 如何保留上个版本的数据 sqlite能实现吗?
- 关于ios内存管理的问题
- ios5基础教程第六章例子疑问
- NSURLConnection 请求服务器问题
- ios8.0弃用了UISearchDisplayController推荐使用UISearchController,关键是不会用啊~
- 开发的APP上传至APPstore被拒绝,求分析解决方案。
- 请教大牛,为什么object-c里写的uibutton和和文本输入框只有最左边一点点区域能响应点击事件?
- 有做过填充算法的大神? 求救啊!
- iOS 做视频录制与播放的时候,偶尔出现 [Playback] Failed to queue any items.
- 菜鸟求教,如何让ScrollView填满整个屏幕?
- 新手:请求一个新浪微博发图+文本的demo
- 一款iphone游戏需要外包出去一部分出去,有意者可以联系,限南京开发者
message:info
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"确定", nil];
alertView.tag = 1001;
[alertView show];
[alertView release];弹出框应该这样写,必须先设置它的tag再show出来,才管用弹出框的委托方法