iphone - 我可以将参数传递给 clickedButtonAtIndex 这是 iphone 方法吗?

标签 iphone objective-c xcode cocoa-touch

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    ....
}

我正在通过 Xcode 开发 iphone 应用程序。

当我点击 UIAlertView 的按钮时,我必须修改那个方法中的一些局部变量。

我想在该方法中控制一些局部变量。

那么有没有办法将变量作为参数传递?

最佳答案

不,您不能将任何其他内容传递给该方法,但是如果您要修改局部变量,那有什么意义呢?如果您想使用该方法的一些信息,则必须在实例变量中设置该信息.

例如,在显示您的 AlertView 之前:

self.myInstanceVariable = valueIWillNeedWhenClicked;
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
    alertView.delegate = self;

    [alertView show];
    [alertView release];

Then on method:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *valueINeed = self.myInstanceVariable
}

关于iphone - 我可以将参数传递给 clickedButtonAtIndex 这是 iphone 方法吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7728365/

相关文章:

iphone - 如何在iPhone中更改UITextView最后输入的文本颜色?

iphone - UIWebView webViewDidStartLoad 有时不触发

iphone - 在没有配置文件的情况下在 iPhone 上安装 .ipa 文件?

ios - 从 ViewController 移除阴影

ios - iPad 横向启动图像逆时针旋转 90 度

xcode - 我的代码有什么问题(云套件)

iPhone键盘返回键颜色

iphone - 无法从字符串转换日期

objective-c - 子类 mac OS colorpickers 以添加按钮

ios - 将模态视图 Controller 与 UITabBarController 和 UINavigationBar 结合使用