Xcode “Application windows are expected to have a

2019-03-03 05:28发布

问题:

I am very new to this, and I am making my first app. When I try to run it, xcode says it was successful, but the simulator just gives me a black screen and I get this message. Here is my main.m code:

    @implementation ViewController

    @synthesize button;

    @synthesize text;

    - (IBAction)pushButton:(id)sender 
    {
        CGRect webRect=CGRectMake(10, 10, 2048, 1536);
        UIWebView *myWebview = [[UIWebView alloc] initWithFrame:webRect];
        myWebview.scalesPageToFit = YES;
        NSURL *url = [NSURL URLWithString:@"http://www.coronetjck/schedule"];
        NSURLRequest *request = [NSURLRequest requestWithURL:url];
        [myWebview loadRequest:request];
         [self.view addSubview:myWebview];
     }
    //web view after pushing button

     -(void)loadView {
         NSString *moviePath = [[[NSBundle mainBundle] resourcePath]
    stringByAppendingPathComponent:@"the_people_vs._george_lucas_teaser_hd_teaser_2_640x360.mp4"];

        MPMoviePlayerController *moviePlayer = [[MPMoviePlayerController alloc]      initWithContentURL:[NSURL fileURLWithPath:moviePath]];

        moviePlayer.movieControlMode = MPMovieControlModeDefault;

        [[NSNotificationCenter defaultCenter] addObserver:self    selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; 

        [moviePlayer play];
     }
     //video

     - (void)viewDidLoad
     {
         [super viewDidLoad];
         // Do any additional setup after loading the view, typically from a nib.
    }

    - (void)viewDidUnload
     {
         [self setButton:nil];
         [self setText:nil];
         [super viewDidUnload];
            // Release any retained subviews of the main view.
    }

     - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
          return YES;
    }

     @end

I am not sure what I did wrong, could someone maybe help me out? I'd greatly appreciate it.