Tim
Tim

Reputation: 113

Convert a HTML page to a iOS View

i want to take a normal html page (a page from tf2 wiki) and convert it into a view. For example it should take a text and put it into a label or a Image into an UIImageView. Is there any Framework to do something like that or should i convert the site on a webserver to make it easier for the app at runtime to render ? Hope you understand, what i want to do. Tim

Upvotes: 2

Views: 1302

Answers (3)

nsgulliver
nsgulliver

Reputation: 12671

there could be different ways depending on your scenario, you could load them in UIWebView within IOS, If you don't want show the UIWebView then you can get the html from it ans use it however you want. or other way you could transfer the HTML as json data to IOS and then show that data via UIView, UILabel or anything else. otherwise as suggested by Zakaria, you could use PhoneGap.

UPDATE with sample code for sending a request and getting its contents if you don't want to use UIWebView

       //your html page with url  
       NSURL *url = [NSURL URLWithString:@"www.google.com"];


        NSURLRequest *request=[NSURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30.0f];

        NSOperationQueue *queue=[[NSOperationQueue alloc]init];
        [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {

            if ([data length]>0 && error==nil) {

                NSString *html=[[NSString alloc]initWithData:data encoding:NSUTF8StringEncoding];

                NSLog(@"this string contains all html page you have \n %@",html);
            }
   }
     ];

Upvotes: 2

Zakaria
Zakaria

Reputation: 15070

If your page is a static one, then use PhoneGap : It will embed your HTML+JS+CSS in an iOS app and will be loaded in a webview.

But there is no framework that will allow you to convert your HTML elements into native ones.

Upvotes: 0

Jeger
Jeger

Reputation: 500

Not sure if i understand the question properly, but Cordova lets you develope iOS apps in html/css/js. Check their website: http://cordova.apache.org/

Upvotes: 0

Related Questions