Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8554993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:00:58+00:00 2026-06-11T15:00:58+00:00

I am trying to dynamically create a UIWebView inside a class file upon launching

  • 0

I am trying to dynamically create a UIWebView inside a class file upon launching the application.

I have successfully gotten a function to be called inside that class file upon launching, but when I add the the code to create the webview to that function, I am getting errors like this: “Tried to obtain the web lock from a thread other than the main thread or web thread. This may be the result of calling to UIKit from a secondary thread. Crashing now…“

My code to create the UIWebView is this:

UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
[webView setDelegate:self];
[webView setHidden:YES];
NSURL *url = [NSURL URLWithString:address];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[webView loadRequest:urlRequest];

Where am I going wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T15:00:59+00:00Added an answer on June 11, 2026 at 3:00 pm

    You are creating the webview from a background thread, which is not allowed by Apple and makes your app crash.
    You should use dispatch_async to create your webview from the main thread :

    dispatch_async(dispatch_get_main_queue(), ^{
        UIWebView *webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 16, 16)];
        [webView setDelegate:self];
        [webView setHidden:YES];
        NSURL *url = [NSURL URLWithString:address];
        NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
        [webView loadRequest:urlRequest];   
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to dynamically create an XML file using php like this: header
I'm trying to dynamically create a set of labels in my XUL Runner application.
So I'm trying to dynamically create a folder inside the web pages folder. I'm
I'm trying to dynamically create this function: svg.path($('#shape23'), path.move(333,410) .smoothC(333,410,333,410) .smoothC(217.5,415.75,217.5,415.75) .smoothC(333,500,333,500) .close(), {fill:
Ladies & Gentlemen, Short Version: Trying to dynamically create a Spine Model Class. Basically
I'm trying to dynamically create a bunch of class properties, but each dynamic fget
I have an application whereby I dynamically create controls on a form from a
SOLUTION removeChild: function(select) { $(select).nextAll().remove(); } I am trying to dynamically create a chain
i'm trying to create dynamically generated icon list for tiny mce. I have written
I'm trying to dynamically create a navbar from data i fetch from a web

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.