- (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/