Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chris69d

macrumors newbie
Original poster
Mar 1, 2012
2
0
I am very new to iphone app dev, this is my first app i'm building. I'm trying to get local image to show up with no success. This is the code...


Code:
- (void) createContentPages
{
    
    NSMutableArray *pageStrings = [[NSMutableArray alloc] init];
    for (int i = 1; i < 5; i++)
    {
        
        NSString *contentString = [[NSString alloc]
                                   initWithFormat:@"<html><head></head><body style='padding:0px;margin:0px;'><img src='page%d.jpg' width='320' height='460' /></body></html>", i, i];
 
        [pageStrings addObject:contentString];
        
    }
    pageContent = [[NSArray alloc] initWithArray:pageStrings];
    
}

The code works fine, if i switch the image source to the files hosted remotely it works, but i don't want remote, i want them locally viewed. Any help will be appreciated
 
Have you included the files (page(number).jpg) in your project?

included them yes

You will probably need to set the document base URI to point inside you app (so a file URI).
How do i do that? This is my first time coding in Obj C.

Does this bit of code need editing?
Code:
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [webView loadHTMLString:dataObject 
                    baseURL:[NSURL URLWithString:@""]];
    
}
 
How do i do that? This is my first time coding in Obj C.

Does this bit of code need editing?
Code:
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [webView loadHTMLString:dataObject 
                    baseURL:[NSURL URLWithString:@""]];
    
}

The basics are nothing to do with Objective-C and everything to do with fairly basic HTML. You need a base tag in the head of the document.

The path to your app can be found with NSBundle methods. You can use that to create a file NSURL which you can turn into a string.

If you expect code, sorry, I see no value in spoon feeding people answers.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.