Notice
Recent Posts
Recent Comments
Link
투케이2K
161. (Objective-C/objc) [간단 소스] WKWebview 웹뷰 runJavaScriptConfirmPanelWithMessage Confirm 팝업창 이벤트 감지 본문
Objective-C
161. (Objective-C/objc) [간단 소스] WKWebview 웹뷰 runJavaScriptConfirmPanelWithMessage Confirm 팝업창 이벤트 감지
투케이2K 2024. 9. 22. 19:41[개발 환경 설정]
개발 툴 : XCODE
개발 언어 : OBJECTIVE-C
[소스 코드]
// ----------------------------------------------------------------------
// [사전 설정 사항]
// ----------------------------------------------------------------------
// 1. WKUIDelegate 정의 필요 :
//
// @interface ViewController : UIViewController <WKUIDelegate , WKNavigationDelegate , WKScriptMessageHandler>
// ----------------------------------------------------------------------
// 2. 딜리게이트 정의 필요 :
//
// [webView setUIDelegate:self];
// ----------------------------------------------------------------------
// ----------------------------------------------------------------------
// [소스 코드]
// ----------------------------------------------------------------------
- (void)webView:(WKWebView *)webView runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(BOOL))completionHandler{
UIAlertController * alert = [UIAlertController
alertControllerWithTitle:@"알림"
message:message
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction
actionWithTitle:@"확인"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
completionHandler(YES);
}];
UIAlertAction* cancel = [UIAlertAction
actionWithTitle:@"취소"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
completionHandler(NO);
}];
[alert addAction:ok];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];
}
// ----------------------------------------------------------------------
반응형
'Objective-C' 카테고리의 다른 글
Comments