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?
Asked
Active
Viewed 1,100 times
3

rishi
- 11,779
- 4
- 40
- 59

Deprecated Darren
- 895
- 7
- 17
-
1there 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. – rishi Jul 10 '14 at 17:30
-
BOOM! that seemed to do the trick! thanks! – Deprecated Darren Jul 10 '14 at 17:45
-
Good, might be this can be posted as answer and you can accept and close the question!! – rishi Jul 10 '14 at 17:49
-
@DeprecatedDarren please can you tell me how you do it? – Rakesh Mandloi Mar 29 '18 at 10:20
1 Answers
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.

rishi
- 11,779
- 4
- 40
- 59
-
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 – Rakesh Mandloi Mar 29 '18 at 10:20
-
after loading HTML, you want to change header fields in shouldStartLoadRequest? – rishi Mar 29 '18 at 12:53
-
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. – Rakesh Mandloi Apr 02 '18 at 05:32