ios - Show HTML - passing data Property Lists -
i ask tips project i'm working on. i'm xcode beginner, maybe more easy i'm thinking.
so, application want create shows collection of data between 2 tableviews , shows image in view controller @ end. i've implemented property lists manage data between tableviews , viewcontroller.
now, here problem, show (in last viewcontroller) html file (stored in resource folder) rather image. can me write down code that? i've been able write code image far, is:
viewcontroller.h
#import <uikit/uikit.h> @interface methodsviewcontroller : uiviewcontroller @property uiimage *bookcover; @property iboutlet uiimageview *bookcoverview; @end
viewcontroller.m
#pragma mark - #pragma mark view life cycle - (void)viewdidload { [super viewdidload]; if (self.bookcover) { [self.bookcoverview setimage:self.bookcover]; } } @end
secondtableview.m
prepare segue
- (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath { [tableview deselectrowatindexpath:indexpath animated:yes]; // fetch book cover nsdictionary *book = [self.books objectatindex:[indexpath row]]; self.bookcover = [uiimage imagenamed:[book objectforkey:@"cover"]]; // perform segue [self performseguewithidentifier:@"methodsviewcontroller" sender:self]; } @end
well, need deal uiwebview
this. add uiwebview
property class:
@property (nonatomic, strong) uiwebview *awebview;
next, need represent content of html
file nsstring
, , content main page.
lets call parameter webtext
, in future load web view, first, - need it.
webtext
parameter nsstring
, try following code:
nserror* error = nil; nsstring *path = [[nsbundle mainbundle] pathforresource: @"nameofyourhtmlfile" oftype: @"html"]; nsstring *webtext = [nsstring stringwithcontentsoffile: path encoding:nsutf8stringencoding error: &error];
set frame awebview
in storyboard, can load html
this:
[self.awebview loadhtmlstring: webtext baseurl: nil];
Comments
Post a Comment