Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Google Sign In with OpenID
Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.

load UIImage from array upon selected index

gbennagbenna Posts: 99Registered Users
I am working on a coverflow app. I have the app so that when a specific cover image is double tapped a new xib is pushed onto the screen. As I have it now for each image tapped the same detail view controller loads a different detail xib. so that I can have different images and text. Here is my code.


- (void) coverflowView:(TKCoverflowView*)coverflowView coverAtIndexWasDoubleTapped:(int)index{


NSLog(@"Index: %d",index);
if (index ==0){
LeafDetailViewController *detailViewController = [[LeafDetailViewController alloc] initWithNibName:@"LeafDetailViewController" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
}
else if (index ==1){
LeafDetailViewController *detailViewController = [[LeafDetailViewController alloc] initWithNibName:@"LeafDetailViewController2" bundle:nil];
[self.navigationController pushViewController:detailViewController animated:YES];
}

}

I would rather just load the same detail view controller and the same detail xib. and just load the images and text that goes with the cover image chosen from an array.

Here is the array

covers = [NSArray arrayWithObjects:
[UIImage imageNamed:@"0002. LIquidambar Acalycina .jpg"],
[UIImage imageNamed:@"0003. Liquidambar Formosana.jpg"],
[UIImage imageNamed:@"0004. Liquidambar Orientalis Oriental Sweetgum1.jpg"],
[UIImage imageNamed:@"0005. Liquidambar Styraceflua Sweetgum2.jpg"],
[UIImage imageNamed:@"0023. Kalopanax Septemlobus Castor Aralia1.jpg"],
[UIImage imageNamed:@"0024. Metapanax DavidII 1.jpg"],
[UIImage imageNamed:@"0024. Metapanax DavidII 3.jpg"],
[UIImage imageNamed:@"0082. Alangium Chinense1.jpg"],
[UIImage imageNamed:@"0145. Quercus Alba White Oak1.jpg"],nil];


and here is my .h file for the detail view controller


#import

@interface LeafDetailViewController : UIViewController < UIImagePickerControllerDelegate, UINavigationControllerDelegate>{
IBOutlet UIImageView *imageView;
IBOutlet UIImageView *imageView2;
UITextView *myText;
NSArray *covers;


}

@property (nonatomic, retain) IBOutlet UIImageView *imageView;
@property (nonatomic, retain) IBOutlet UIImageView *imageView2;
@property (nonatomic, retain) UITextView *myText;
@property (nonatomic, retain) IBOutlet UIButton *takePhotoButton;
@property (nonatomic, retain) NSArray *covers;
-(IBAction) getPhoto:(id) sender;
@end


can anyone help me to do this. I am a rather newbie at this and would really appreciate some help.
Post edited by gbenna on

Replies

  • DomeleDomele Posts: 2,948Registered Users
    1. Create a UIImage property in LeafDetailViewController.

    2. In viewWillAppear, set this UIImage to the appropriate image view.

    3. Now when you allocate LeafDetailViewController, retrieve the selected image using NSArray's objectAtIndex: method passing in "index" (assuming you are doing this from coverflowView:(TKCoverflowView*)coverflowView coverAtIndexWasDoubleTapped:(int)index.

    4. Set the LeafDetailViewController's image property with the image you just got from the array.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • gbennagbenna Posts: 99Registered Users
    Domele;408746 said:
    1. Create a UIImage property in LeafDetailViewController.

    2. In viewWillAppear, set this UIImage to the appropriate image view.

    3. Now when you allocate LeafDetailViewController, retrieve the selected image using NSArray's objectAtIndex: method passing in "index" (assuming you are doing this from coverflowView:(TKCoverflowView*)coverflowView coverAtIndexWasDoubleTapped:(int)index.

    4. Set the LeafDetailViewController's image property with the image you just got from the array.
    I'm not sure what you are saying.

    This is what I put in
    - (void) coverflowView:(TKCoverflowView*)coverflowView coverAtIndexWasDoubleTapped:(int)index{

    LeafDetailViewController *detailViewController = [[LeafDetailViewController alloc] initWithNibName:@"LeafDetailViewController" bundle:nil];

    detailViewController.imageView= [covers objectAtIndex:index];
    [self.navigationController pushViewController:detailViewController animated:YES];
    }


    and this is in the viewDidLoad


    - (void)viewDidLoad
    {
    [super viewDidLoad];

    imageView.image = [UIImage imageNamed: @"index"];



    }

    I know this isn't right

    could you please help me.
  • DomeleDomele Posts: 2,948Registered Users
    Let's start with properties. Do you know what a property is and how to set one up? I'm guessing not since you didn't the do the 1st step correctly. Here is a guide: http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/26587-slicks-definitive-guide-properties.html

    Once you've read that, do the 1st step and post the header file of LeafDetailViewController.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • gbennagbenna Posts: 99Registered Users
    Domele;409061 said:
    Let's start with properties. Do you know what a property is and how to set one up? I'm guessing not since you didn't the do the 1st step correctly. Here is a guide: http://www.iphonedevsdk.com/forum/iphone-sdk-tutorials/26587-slicks-definitive-guide-properties.html

    Once you've read that, do the 1st step and post the header file of LeafDetailViewController.
    OK I read and reread but when I did some of the code I got errors and warning until I did it this way.


    - (void)viewDidLoad
    {
    [super viewDidLoad];

    UIImage *image = [[UIImage alloc] init];
    self .imageView.image =image;


    }


    I noticed now that apple doesn't let you release so I left those out.

    I hope I did this ok.
  • DomeleDomele Posts: 2,948Registered Users
    No. A UIViewController's views should be private. Only the view controller itself should alter them or use them. Create a UIImage property and use that in viewWillAppear to assign your imageView's image property.
    If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.



    New app - See screenshots and details at www.globaclock.com.



    If you want to
  • gbennagbenna Posts: 99Registered Users
    Domele;409085 said:
    No. A UIViewController's views should be private. Only the view controller itself should alter them or use them. Create a UIImage property and use that in viewWillAppear to assign your imageView's image property.
    Is this what you meant for me to put in my LeafDetailViewController .m file?



    -(void) viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    UIImage *image = [[UIImage alloc] init];
    self .imageView.image =image;
    }


    before
    -(void) viewDidLoad
Sign In or Register to comment.