티스토리 뷰

Mobile/iOS

[iOS]UIWebViewDelegate의 이용

out of coding 2016. 3. 9. 15:23

<UIWebViewDelegate>의 이용


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;

  : 호출되는 URL이 어떤것이 있는지 확인 가능하다.

  UIWebViewNavigationType{

    UIWebViewNavigationTypeLinkClicked, // 링크 클릭 : 0

    UIWebViewNavigationTypeFormSubmitted, // 양식 제출 : 1

    UIWebViewNavigationTypeBackForward, // 뒤로, 앞으로 : 2

    UIWebViewNavigationTypeReload, // 새로고침 : 3

    UIWebViewNavigationTypeFormResubmitted, // 양식 다시 제출 : 4

    UIWebViewNavigationTypeOther // 기타 : 5


- (void)webViewDidStartLoad:(UIWebView *)webView;

- (void)webViewDidFinishLoad:(UIWebView *)webView;

  : 웹페이지 URL을 시작하고 끝낼때 호출됨.


- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error

  : error가 발생할 때 호출됨. 

error.description : error 코드 포함 + 설명

error.code : error 코드


 ex) error code = -1009 인터넷이 연결안되어 있을 때


NS_ENUM(NSInteger)

{

    NSURLErrorUnknown = -1,

    NSURLErrorCancelled = -999,

    NSURLErrorBadURL = -1000,

    NSURLErrorTimedOut = -1001,

    NSURLErrorUnsupportedURL = -1002,

    NSURLErrorCannotFindHost = -1003,

    NSURLErrorCannotConnectToHost = -1004,

    NSURLErrorNetworkConnectionLost = -1005,

    NSURLErrorDNSLookupFailed = -1006,

    NSURLErrorHTTPTooManyRedirects = -1007,

    NSURLErrorResourceUnavailable = -1008,

    NSURLErrorNotConnectedToInternet = -1009,

    NSURLErrorRedirectToNonExistentLocation = -1010,

    NSURLErrorBadServerResponse = -1011,

    NSURLErrorUserCancelledAuthentication = -1012,

    NSURLErrorUserAuthenticationRequired = -1013,

    NSURLErrorZeroByteResource = -1014,

    NSURLErrorCannotDecodeRawData =             -1015,

    NSURLErrorCannotDecodeContentData =         -1016,

    NSURLErrorCannotParseResponse =             -1017,

    NSURLErrorAppTransportSecurityRequiresSecureConnection NS_ENUM_AVAILABLE(10_11, 9_0) = -1022,

    NSURLErrorFileDoesNotExist = -1100,

    NSURLErrorFileIsDirectory = -1101,

    NSURLErrorNoPermissionsToReadFile = -1102,

    NSURLErrorDataLengthExceedsMaximum NS_ENUM_AVAILABLE(10_5, 2_0) = -1103,

    

    // SSL errors

    NSURLErrorSecureConnectionFailed = -1200,

    NSURLErrorServerCertificateHasBadDate = -1201,

    NSURLErrorServerCertificateUntrusted = -1202,

    NSURLErrorServerCertificateHasUnknownRoot = -1203,

    NSURLErrorServerCertificateNotYetValid = -1204,

    NSURLErrorClientCertificateRejected = -1205,

    NSURLErrorClientCertificateRequired = -1206,

    NSURLErrorCannotLoadFromNetwork = -2000,

    

    // Download and file I/O errors

    NSURLErrorCannotCreateFile = -3000,

    NSURLErrorCannotOpenFile = -3001,

    NSURLErrorCannotCloseFile = -3002,

    NSURLErrorCannotWriteToFile = -3003,

    NSURLErrorCannotRemoveFile = -3004,

    NSURLErrorCannotMoveFile = -3005,

    NSURLErrorDownloadDecodingFailedMidStream = -3006,

    NSURLErrorDownloadDecodingFailedToComplete =-3007,


    NSURLErrorInternationalRoamingOff NS_ENUM_AVAILABLE(10_7, 3_0) =         -1018,

    NSURLErrorCallIsActive NS_ENUM_AVAILABLE(10_7, 3_0) =                    -1019,

    NSURLErrorDataNotAllowed NS_ENUM_AVAILABLE(10_7, 3_0) =                  -1020,

    NSURLErrorRequestBodyStreamExhausted NS_ENUM_AVAILABLE(10_7, 3_0) =      -1021,

    

    NSURLErrorBackgroundSessionRequiresSharedContainer NS_ENUM_AVAILABLE(10_10, 8_0) = -995,

    NSURLErrorBackgroundSessionInUseByAnotherProcess NS_ENUM_AVAILABLE(10_10, 8_0) = -996,

    NSURLErrorBackgroundSessionWasDisconnected NS_ENUM_AVAILABLE(10_10, 8_0)= -997,

};


'Mobile > iOS' 카테고리의 다른 글

[iOS]NSMutableURLRequest 사용  (0) 2016.03.09
[iOS]NSTimer  (0) 2016.03.09
[iOS]NetworkStatus 체크  (0) 2016.03.09
[iOS]UIView Animation  (0) 2016.03.09
[iOS]UITableView cell 갱신  (0) 2016.03.09
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2025/01   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함