2013-09-16 3 views
0

Я делаю простое приложение без Xcode, используя Теос на айподе, и я хочу, чтобы приложение просто загрузить http://www.google.com/UIWebView может привести к сбою моего приложения?

Когда я начинаю мое приложение, экран становится черным, а затем падает через 10 секунд. Я считаю, что это имеет какое-то отношение к моему использованию UIWebView, но я не уверен. Я делаю что-то явно неправильно? Что я могу сделать, чтобы выяснить, что происходит?

У меня есть 4 файла:
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 *[email protected]"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 
+0

Define не работает - что не работает? –

+0

Когда я запускаю приложение, экран становится черным, а затем падает через 10 секунд. – VladHQ

ответ

0

Пожалуйста, используйте вместо этого:

@implementation RootViewController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    webview=[[UIWebView alloc]initWithFrame:self.view.bounds]; 
    NSString *[email protected]"http://www.google.com"; 
    NSURL *nsurl=[NSURL URLWithString:url]; 
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl]; 
    [webview loadRequest:nsrequest]; 
    [self.view addSubview:webview]; 
} 
@end 
Смежные вопросы