Question

I have a TableViewCOntroller that shows a list of images and associated descriptions. I pass data to the detailed view in the prepare for segue method. THe MSMutableDrictionary Object I pass has the correct values and I can see this in the NSLog of the object in the detail views viewDidLoadMethod. THe code for this is as follows:

.h of detail view controller

@interface sitespecLargeImageDetail : UIViewController
@property (strong, nonatomic) NSMutableDictionary *details;
@property (strong, nonatomic) IBOutlet UIImage *largeImage;
@property (strong, nonatomic) IBOutlet UILabel *largeImageLabel;
@end

.m of detail view controller

@implementation sitespecLargeImageDetail

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.

_largeImage = [_details valueForKey:@"pbvurl"];
_largeImageLabel = [_details valueForKey:@"pbvdesc"];


NSLog(@"%@",  _largeImageLabel);


}

- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

Here is the prepare for segue event in the tableviewcontoller:

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
sitespecLargeImageDetail *detailViewController = (sitespecLargeImageDetail    *)segue.destinationViewController;
detailViewController.details = _dictObj;

}

Couple of strange things:

  1. WHen I look at the detail view controller in my storyboard in the connections inspector, I can see both the label and image Outlets. I can see I ahve connected the label outlet. great, but it does not update when the view loads! I know the dict obj in the detail view gets data because I can NSLog it and see it. I use that to set the IBOutlet for the label but nothing.
  2. In the connection inspector, I can see the UIImage outlet BUT I am unable to connect it to the UIImage VIew I placed in the detail view controller, it simply wont allow me to connect it, no error, just when I control drag from the detailview controller I dont even see it! I see the label outlet, but not the image view.......
Was it helpful?

Solution

Firstly, what you want to do is _largeImageLabel.text = [_details valueForKey:@"pbvdesc"];.

Without the .text what you are doing is using the UILabel pointer to point to a NSString, which clearly does not result in your expected behaviour!

As for the UIImage outlet, what you need is a UIImageView outlet! UIImage is not a view, hence it doesn't have any relation with the interface builder (you can't drag a UIImage in your storyboard, only views can compose interfaces).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top