3

I have a UIWebView that i am loading using loadHTMLString and i need to set cookies on the request header. I know how to do this using loadRequest but not loading the webview with loadHTMLString I don't have the request object. Has anyone done anything like this?

4
  • 1
    there will not be any difference between loading web view from loadRequest vs loadHTMLString method, shouldStartLoadWithRequest method will be called in both cases. You can override your headers there. Commented Jul 10, 2014 at 17:30
  • BOOM! that seemed to do the trick! thanks! Commented Jul 10, 2014 at 17:45
  • Good, might be this can be posted as answer and you can accept and close the question!! Commented Jul 10, 2014 at 17:49
  • @DeprecatedDarren please can you tell me how you do it? Commented Mar 29, 2018 at 10:20

1 Answer 1

2

There will not be any difference between loading web view from loadRequest vs loadHTMLString method, shouldStartLoadWithRequest method will be called in both cases. You can override your headers there and add header as per your requirements.

Sign up to request clarification or add additional context in comments.

3 Comments

i have the same issue while loading HTML string with loadHTMLString and than add header field in shouldStartLoadWithRequest and than load request my loaded HTML is getting blank
after loading HTML, you want to change header fields in shouldStartLoadRequest?
Thanks for reply rishi, Yes I want but the issue is when is update header and then load request which is in shouldStartLoadRequest so my HTML is getting blank.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.