0

I am making a simple app without Xcode, using Theos on my iPod, and I want the app to just load http://www.google.com/

When I start my app, the screen becomes black, and then crashes after 10 seconds. I believe it has something to do with my use of the UIWebView, but I'm not sure. Am I doing something obviously wrong? What can I do to figure out what is happening?

I have 4 files:
main.m:

int main(int argc, char **argv) {
        NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
        int ret = UIApplicationMain(argc, argv, @"comvlad1kwebApplication", @"comvlad1kwebApplication");
        [p drain];
        return ret;
}

// vim:ft=objc

RootViewController.h:

@interface RootViewController: UIViewController {
UIWebView *webview;
}
@end

RootViewController.mm:

#import "RootViewController.h"

@implementation RootViewController

- (void)loadView {
    webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, 1024,768)];
    NSString *url=@"http://www.google.com";
    NSURL *nsurl=[NSURL URLWithString:url];
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
    [webview loadRequest:nsrequest];
    [self.view addSubview:webview];
}
@end

Makefile:

include theos/makefiles/common.mk

APPLICATION_NAME = comvlad1kweb
comvlad1kweb_FILES = main.m comvlad1kwebApplication.mm RootViewController.mm
comvlad1kweb_FRAMEWORKS = UIKit CoreGraphics Foundation

include $(THEOS_MAKE_PATH)/application.mk
4

1 回答 1

0

Please use this instead:

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    webview=[[UIWebView alloc]initWithFrame:self.view.bounds];
    NSString *url=@"http://www.google.com";
    NSURL *nsurl=[NSURL URLWithString:url];
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
    [webview loadRequest:nsrequest];
    [self.view addSubview:webview];
}
@end
于 2013-09-16T11:55:46.830 回答