2011-10-11 2 views
3
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    .... 
} 

저는 Xcode로 아이폰 앱을 개발 중입니다.iphone 메소드 인 clickedButtonAtIndex에 매개 변수를 전달할 수 있습니까?

UIAlertView 단추를 클릭하면 해당 메서드에서 일부 로컬 변수를 수정해야합니다.

해당 메서드에서 일부 로컬 변수를 제어하려고합니다.

매개 변수로 변수를 전달하는 방법이 있습니까?

답변

3

아니요 그 방법에 다른 것을 전달할 수는 없지만 지역 변수를 수정 한 다음 그 점이 무엇입니까?, 해당 방법에 대한 정보를 사용하려면 해당 정보를 인스턴스에 설정해야합니다 변하기 쉬운.

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 
} 
: 그래서

예를 들어이처럼 AlertView 뭔가를 표시하기 전에

관련 문제