UIAlertControllerStyleActionSheet
의 에 대한 목표 -c 쓰기를 사용하고 있습니다.iOS 팝업 표시가 두 번 표시됩니다.
iPhone에서 알림 시트를 표시하고 iPad에서 popoverPresentationController
을 표시하고 싶습니다.
먼저 UIPopoverPresentationControllerDelegate
대리인을 설정했습니다.
버튼을 클릭하면 팝업이 올바르게 표시됩니다.
하지만 화면을 클릭하여 팝업을 닫습니다. 아래에 경고가 표시됩니다.
[경고] < _UIPopoverBackgroundVisualEffectView 0x14be52ef0>에 불투명도를 적용하라는 메시지가 표시됩니다. 이렇게하면 불투명도가 1로 돌아갈 때까지 효과가 깨집니다.
이제 버튼을 클릭하면 다시 팝보기가 표시됩니다.
로그가 아래에 표시됩니다.
인해 캐치되지 않는 예외 'NSGenericException'응용 프로그램 종료, 이유는 : '응용 프로그램이 스타일 UIAlertControllerStyleActionSheet의 UIAlertController()을 선물했다. 이 스타일을 사용하는 UIAlertController의 modalPresentationStyle은 UIModalPresentationPopover입니다. 경고 컨트롤러의 popoverPresentationController를 통해이 팝업에 대한 위치 정보를 제공해야합니다. sourceView와 sourceRect 또는 barButtonItem을 제공해야합니다. 경고 컨트롤러를 제시 할 때이 정보를 알 수없는 경우 UIPopoverPresentationControllerDelegate 메소드 -prepareForPopoverPresentation에 정보를 제공 할 수 있습니다. *** 먼저 투사 호출 스택 : (0x18d9a41c0 0x18c3dc55c 0x19418a8b0 0x193ac60a8 0x193ac3df4 0x193a08d0c 0x1939faac0 0x19376a22c 0x18d9517dc 0x18d94f40c 0x18d94f89c 0x18d87e048 0x18f2ff198 0x1937e2b50 0x1937dd888 0x10011198c의 0x18c8605b8) 의 libC++ abi.dylib : NSException
형 캐치되지 제외 종료
누구든지 문제를 해결하는 방법을 알고 있습니까?
내 코드는 다음과 같습니다 :
@interface ViewController() <...UITextViewDelegate,UITextFieldDelegate...> {
UIAlertController *alertTypeAlertController;
UIAlertAction *alertType1Action;
UIAlertAction *alertType2Action;
UIPopoverPresentationController *popPresenter;
}
- (void)viewDidLoad {
[super viewDidLoad];
alertTypeAlertController = [UIAlertController
alertControllerWithTitle:@"selecte one:"
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
alertType1Action = [UIAlertAction
actionWithTitle:@"Type1"
style:UIAlertActionStyleDefault
handler:nil];
alertType2Action = [UIAlertAction
actionWithTitle:@"Type2"
style:UIAlertActionStyleDefault
handler:nil];
[alertTypeAlertController addAction: alertType1Action];
[alertTypeAlertController addAction: alertType2Action];
// for ipad
popPresenter = [alertTypeAlertController popoverPresentationController];
popPresenter.permittedArrowDirections = UIPopoverArrowDirectionLeft;
popPresenter.delegate = self;
popPresenter.sourceView = self.theTypeBtn;
popPresenter.sourceRect = CGRectMake(230, 22, 10, 10);
....
}
- (void)popoverPresentationControllerDidDismissPopover:(UIPopoverPresentationController *)popoverPresentationController {
// called when a Popover is dismissed
}
- (BOOL)popoverPresentationControllerShouldDismissPopover:(UIPopoverPresentationController *)popoverPresentationController {
// return YES if the Popover should be dismissed
// return NO if the Popover should not be dismissed
return YES;
}
-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller {
return UIModalPresentationNone;
}
enter code here
가 대단히 감사합니다.
나는, 결과는 여전히 같은 오류를 표시한다 "UIPopoverPresentationController * popPresenter"전에 __weak를 추가하려고합니다. :( – dickfala
검사 두 번째 팝업 당신이 (2)를 제시하려고하면 self.presentedViewController는 무기 호, 일반적으로 응용 프로그램이 충돌하는 경우 보기 컨트롤러. –
첫 번째 클릭 버튼을 확인하고, pop은 nil (self.presentedViewController)이지만 올바르게 표시됩니다. 충돌은 발생하지 않지만 두 번째 버튼을 클릭해도 팝업은 계속 사라집니다. @@ – dickfala