0
A
回答
1
使您的控制器类符合UIAlertViewDelegate协议。
@interface MyViewController : UIViewController <UIAlertViewDelegate>
创建委托警报视图设置为自:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Follow" message:@"me on twitter" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
[alert show];
[alert release];
响应委托方法
- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
if (buttonIndex != [alertView cancelButtonIndex]) {
// open url
}
}
1
的你UIAlertView
的delegate
必须(在大多数情况下,self
)被设置为分类在我的iPhone
对不起IM这是使用它。确保您的班级拨打UIAlertView
确实符合UIAlertViewDelegate
代表。
1
您需要将UIAlertView
的delegate
属性设置为self
而不是nil
并在头中实现协议。
头文件:
@interface MyViewController : UIViewController <UIAlertViewDelegate>
另外,请检查buttonIndex
。目前(执行上述操作之后),如果按下任何按钮,将打开URL。
- (void)alertView: (UIAlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex
{
if (buttonIndex != [alertView cancelButtonIndex])
{
//open url
}
}
+0
应该是如果(buttonIndex = [alertView cancelButtonIndex]!)!! –
相关问题
- 1. UIAlertView其他按钮标题
- 2. UIAlertView按钮操作?
- 3. iOS的UIAlertView中的其他按钮操作
- 4. UIAlertView按钮导致崩溃,当所有其他工作正常
- 5. 使用为GridView A按钮柱作为触发其他的GridView
- 6. UIAlertView按钮动作代码
- 7. 禁用UIAlertView按钮
- 8. 禁用其他按钮点击其他按钮
- 9. 如何链接UIAlertView中的其他按钮以启动Tweeter作曲者?
- 10. UIAlertView灰色按钮
- 11. UIAlertView按钮标记
- 12. 使用UIAlertView检测按钮单击
- 13. 如何使用按钮动作事件来调用其他类?
- 14. 使用其他单选按钮更改单选按钮的值
- 15. 按钮被其他2个按钮
- 16. UIAlertView按钮帧全部为0?
- 17. 动作按钮 - >与其他按钮的小黑色窗口
- 18. 如何使用其他条件按钮上的按钮图像按钮?
- 19. 为什么人们使用按钮和其他HTML输入?
- 20. 使用BOOL作为按钮
- 21. 使用UICollectionViewCell作为按钮
- 22. 使用UISegmentControl作为按钮
- 23. 使用UIView作为按钮
- 24. Grails g:链接按钮显示为大于其他按钮
- 25. Fancybox中的其他按钮
- 26. TextField覆盖UIAlertView的按钮
- 27. UIAlertView按钮来显示viewController
- 28. 更改UIAlertView按钮布局
- 29. UIAlertView无取消按钮?
- 30. IAP iOS UIAlertView取消按钮
感谢大家工作和亚历克斯 – Laaaa