재설정 버튼이있는 응용 프로그램의 카운터가 있지만 탭 한 후 즉시 재설정하는 대신 UIAlertView를 팝업으로 표시하고 사용자가 경고의 단추로 재설정을 다시 시작하게하십시오. 나는 이것에 대해 전반적으로 잘 경험하지 못했기 때문에 아래 코드를 추가/대체하는 것만으로도 충분할 것입니다. 나는이 롤에서 일하고있다. 어떤 도움을 주셔서 감사합니다!UAlertView 내에서의 동작 4.3
- (IBAction)reset {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"titleHere"
message:@"messageHere"
delegate: self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Reset", nil];
alert.tag = TAG_RESET;
[alert show];
}
-(void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
if (alertView.tag == TAG_DEV) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.examplesite.com"]]; // just another alert don't worry about this one
} else if (alertView.tag == TAG_RESET) { // i need help here
}
}
경고 내에서 기본적으로 IBAction입니다.
UPDATE : 가 어떻게 버튼이 통합 것인가?
-(IBAction)zero {
counter=0;
count.text = [NSString stringWithFormat:@"%i",counter];
}
UPDATE2는 :
그래서 지금은 완벽하게 수를 지 웁니다이, 한, 유일한 문제는이 탭 중 하나를 취소하거나 재설정 후 경고 팝업 계속 지금 ...
-(IBAction)resetButtonPushed {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"titleHere"
message:@"messageHere"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Reset", nil];
alert.tag = TAG_RESET;
[alert show];
}
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (alertView.tag == TAG_DEV){
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.examplesite.com"]]; // just another alert don't worry about this one
}
else if (alertView.tag == TAG_RESET) { [self resetButtonPushed]; {
counter=0;
count.text = [NSString stringWithFormat:@"%i",counter];
} if ([[alertView buttonTitleAtIndex:buttonIndex] isEqualToString:@"Reset"]){
// Reset button tapped
}
}
}
나는 당신이 성취하려는 것을 이해하지 못합니다. reset 메소드는 UI에서 버튼을 누를 때 호출됩니다. 재설정 단추가있는 경고를 표시합니다. 사용자가 해당 버튼을 누르면 clickedButton 콜백이 호출됩니다. if (alertView.tag == TAG_RESET)에서 재설정이 눌려 졌음을 알고 있으므로이 시점에서 카운터를 지 웁니다. 내가 뭘 놓치고 있니? –
NJones가 얻은 것을 거의 시도하고 있습니다. – DiscoveryOV