2013-07-13 3 views
1

클라이언트 프로젝트에서 단추 누르기로 UIAlertView을 만들어야합니다. 그 부분은 어렵지 않다과 일을 함께 말했다 코드 :사용자 지정 UIAlertView, 대리인의 메시지 변경

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    if (buttonIndex == 1) { 

     self.currentCountButtonCount++; 

    }if (buttonIndex == 2) { 

     self.currentCountButtonCount--; 

    } 
} 

- (IBAction)countClick:(id)sender { 

    //self.alertMessage = [[NSString alloc]init]; 

    // tallies and keeps current count number 

    if (!self.currentCountButtonCount) 
     self.currentCountButtonCount = 0; 

    NSString *alertMessage = [NSString stringWithFormat:@"%d", self.countButtonCount]; 

    self.countAlert = [[UIAlertView alloc]initWithTitle:@"Count" message:alertMessage delegate:self cancelButtonTitle:@"end" otherButtonTitles:@"+",@"-", nil]; 

    [self.countAlert show]; 
} 

당신이 결함없이 작동이 볼 수 있지만 그것이 내가 달성하기 위해 노력했다 아니다.

UIAlertView의 메시지가 사용자가 UIAlertViews + 버튼을 누를 때 증가 된 문자열로 변경되고 - 버튼을 누르면 감소 된 값이 표시됩니다.

나는 위의 코드가이 작업을 수행 할 것이라고 생각했지만 버튼을 눌렀을 때 경고를 해제합니다. 사용자가 계산을 완료 할 때까지 알림을 유지해야합니다.

어떻게 구현하나요?

나는 사용자 정의 UIAlertView을 시도했지만 실제로는 그래픽 측면에서만 도움이되는 것처럼 보입니다.

+0

이전 질문에서 말했듯이 'UIAlertView'로는이 작업을 수행 할 수 없습니다. 계속 표시되는 동안 메시지를 업데이트 할 수있는 사용자 지정 경고보기 클래스를 찾아야합니다. – rmaddy

+0

그 점은 이해합니다. 그러나 어떻게 커스텀 클래스에서 그 문제를 해결할 수 있습니까? @rmaddy – Keeano

+0

어쩌면 당신은 내가 볼 수 있거나 그것을 설명하는 방법을 알 수있는 좋은 예를 알고 있습니까? @rmaddy – Keeano

답변

0

사용자 정의 UIView을 사용하여 CustomAlertiew을 생성 한 다음이 'CustomAlertiew'에 대해 delegates을 생성 할 수 있습니다.