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 6958185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:06:26+00:00 2026-05-27T15:06:26+00:00

In this subclass of UIWebView, I am looking to set up a method to

  • 0

In this subclass of UIWebView, I am looking to set up a method to create an embedded youtube video. However, no matter how I edit this code (which I found most of online), it is always giving me a warning at the line:

self = [[UIWebView alloc] initWithFrame:frame];

Im not sure whether this is because of Xcode 4.2 or iOS 5 or the fact that I am using self. Is there actually something wrong? If so, how might I fix it?

Entire method code:

- (videosView *)initWithStringAsURL:(NSString *)urlString frame:(CGRect)frame;
{
    if (self = [super init]) 
    {
        // Create webview with requested frame size
        self = [[UIWebView alloc] initWithFrame:frame];

        // HTML to embed YouTube video
        NSString *youTubeVideoHTML = @"<html><head>\
        <body style=\"margin:0\">\
        <embed id=\"yt\" src=\"%@\" type=\"application/x-shockwave-flash\" \
        width=\"%0.0f\" height=\"%0.0f\"></embed>\
        </body></html>"; 

        // Populate HTML with the URL and requested frame size
        NSString *html = [NSString stringWithFormat:youTubeVideoHTML, urlString, frame.size.width, frame.size.height];



        // Load the html into the webview
        [self loadHTMLString:html baseURL:nil];
        [self setUserInteractionEnabled:YES];

    }
    return self;  
}
  • 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-05-27T15:06:27+00:00Added an answer on May 27, 2026 at 3:06 pm

    You already have the memory allocated (pointed to by this), so don’t alloc more:

    self = [super initWithFrame:frame];
    

    And, looking a bit more, you shouldn’t init super twice. Move that statement into the if, instead of the plain super init:

    if (self = [super initWithFrame:frame]) {...} 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This code: (self is a subclass of NSView) rotate = [CABasicAnimation animationWithKeyPath:@transform.rotation.z]; rotate.duration =
In my project most of my code is in my UIView subclass. In this
I have a ParentBean class which has the @ManagedBean annotation. If I subclass this
i want to create a subclass of NSWindow . this subclass needs to initialize
I have a UIViewController subclass which includes a UIWebView and implements the UIWebViewDelegate. What
i am working in creating a custom class which is subclass of UIWebview. But
I found this great subclass of NSWindow , however it does not add any
Similar to this question I have a custom subclass of UITableViewCell that has a
I have a UIView subclass ( CustomView for purposes of this question) that has
I made a custom UITableView subclass and implemented this: - (void)scrollViewDidScroll:(UIScrollView *)scrollView { //

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.