현재 iOS6 및 iOS7을 지원해야하는 앱에서 작업하고 있습니다.UIAlertView alertViewShouldEnableFirstOtherButton : iOS7에서 잘못된 버튼을 사용 중지합니다.
내가 이런 경고를 만드는거야 : 나는 다음과 같은 프로토콜 방식을 구현하고있어 대리자에서
self.newCategoryAlertView = [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"MessageTitleNewCategory", nil)
message:NSLocalizedString(@"MessageTextNewCategory", nil)
delegate:self
cancelButtonTitle:nil
otherButtonTitles:NSLocalizedString(@"ButtonOK", nil), NSLocalizedString(@"ButtonCancel", nil), nil] autorelease];
self.newCategoryAlertView.cancelButtonIndex = 1;
self.newCategoryAlertView.tag = alertViewTypeNewCategory;
self.newCategoryAlertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[self.newCategoryAlertView textFieldAtIndex:0].delegate = self;
[self.newCategoryAlertView textFieldAtIndex:0].autocapitalizationType = UITextAutocapitalizationTypeSentences;
[[self.newCategoryAlertView textFieldAtIndex:0] setReturnKeyType:UIReturnKeyDone];
[[self.newCategoryAlertView textFieldAtIndex:0] setKeyboardAppearance:UIKeyboardAppearanceDefault];
[self.newCategoryAlertView textFieldAtIndex:0].enablesReturnKeyAutomatically = YES;
[self.newCategoryAlertView show];
을
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
{
if(alertView.tag == alertViewTypeNewCategory)
{
UITextField *textField = [alertView textFieldAtIndex:0];
if (!textField.text || [textField.text isEqualToString:@""])
{
return NO;
} else {
return YES;
}
} else {
return YES;
}
}
내 문제는 왼쪽 버튼이 iOS6의 비활성화 실행이 있다는 것이다 (예상대로), iOS7에서 실행하면 오른쪽 버튼이 비활성화됩니다.
델리게이트 메서드 내에서 cancelButtonIndex 및 firstOtherButtonIndex 값을 확인했으며 iOS7 및 iOS6에서 동일합니다.
내가 뭘 잘못하고 있는지 힌트가 있으십니까? 또는이 문제를 해결할 수있는 해결 방법은 무엇입니까?
내가 답을 표시 할 수 있습니다 할 수 있습니다. 그러나 실제로 문제에 대한 설명이나 해결책이 아닙니다. UIAlertView가 firstOtherButtonIndex를 무시하고 항상 첫 번째 버튼을 비활성화하는 것처럼 보입니다. –
수락을 보내 주셔서 감사합니다. 네, 맞습니다. UIAlertView는 iOS 6과 iOS 7 모두에서 첫 번째 버튼을 비활성화하는 것입니다. – nikhilgohil11
우리가이 방법으로 해결해야하는 농담은 거의 ... 지금도 2 년 후 : –