Lined Notebook

[objective-c] javascript 연동했는데 alert 안뜰 때

by 사슴비행기

https://doorganizedcoding.tistory.com/29

swift 글 참고https://doorganizedcoding.tistory.com/29

 

추가한 코드만 적었다.

#import <WebKit/WebKit.h>

@interface EasyWKWebViewController : UIViewController<WKUIDelegate>

@end
_webView.UIDelegate = self;
- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler {
    
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:message preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:[UIAlertAction actionWithTitle:@"확인" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        completionHandler();
    }]];
    
    [self presentViewController:alert animated:true completion:nil];
}

'objective-c > tip' 카테고리의 다른 글

autolayout 미리 만들어둔 변수에 연결  (0) 2019.08.29

블로그의 정보

Beautiful Coding

사슴비행기

활동하기