Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6199587
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:12:55+00:00 2026-05-24T04:12:55+00:00

fairly new to Objective-C and iOS development (coming from PHP) and I have a

  • 0

fairly new to Objective-C and iOS development (coming from PHP) and I have a relatively simple question that I can’t seem to find an answer to:

I am following along with an example for split View design where a web page is loaded into the Detail View when a user clicks an item in the master view. I got all this working, but would like to substitute web view for an image. So I’ve amended the app to load a UIImage instead of a WebView. What I’m looking for is the equivalent to this code:

NSString *urlString = [pagesAddress objectAtIndex:indexPath.row];
NSURL *url = [NSURL URLWithString:urlString];

// these 2 is where I get lost with the images.
NSURLRequest = *request = [NSURLRequest requestWithURL:url];
[detailViewController.webView loadRequest:request];

I came up with this:

NSString *imageName = [pagesAddress objectAtIndex:indexPath.row];
UIImage *myImage = [UIImage imageNamed:imageName];

// missing the last 2 calls: one to tell Xcode that it's an image "request" I want and the second to load the actual image (based on it's name that is already in an array) into the ImageView.

Thanks.

PS

I tried this:

NSString *imageName = [pagesAddress objectAtIndex:indexPath .row];
[detailViewController.imageView setImage:[UIImage imageNamed:imageName]]; 

And it shows just the first image, then crashes when I try to show the last one.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T04:12:56+00:00Added an answer on May 24, 2026 at 4:12 am

    In the end, the solution were those 2 lines when I amended the code:

    NSString *imageName = [pagesAddress objectAtIndex:indexPath.row];
    [detailViewController.imageView setImage:[UIImage imageNamed:imageName]];
    

    Notice that I had to change the setImage to convert the NSString to a UIImage or Xcode would complain. It turns out it was crashing because in the array where I had the image names, I had put 3 images into one entry (basically I forgot the commas!) so it was out of range.

    Tim:

    This line you gave me

    UIImageView *imageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
    

    is unnecessary because I already have a view created, it would create another view which I never used. Also, replacing it with CGRect seems overkill if I already have a UIImage placeholder no?

    In any case, it works now and I’m very grateful for all the help. iPad development with Objectve-C is a very thorny road and I expect I’ll be bugging you guys some more.

    Cheers.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am fairly new to Objective C and iOS programming but am constantly trying
I'm fairly new to Objective-C and I can't figure out how to wait in
I am fairly new to Objective-C. Currently porting my own library from C#/Java to
Hey all! I'm fairly new to objective-c so I have never had to tackle
Being fairly new to Spring I have a question about annotating a class. When
I am still fairly new to C# and I have a question regarding attributes.
I am fairly new to objective c and cocoa, however i have spent a
I am fairly new with Objective C and getting my feet wet! I have
I am fairly new to Emacs and I have been trying to figure out
im fairly new to objective-c, most of it is clear however when it comes

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.