Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't set UIImageView
    primarykey
    data
    text
    <p>I have a class that parses the result of a web service call. Based on that result it calls a method in another class and that method is supposed to change the image in a UIImageView. But it won't set the image and I have no idea why.</p> <p>First class relevant parts. 'Server' value does come back "rb".</p> <pre><code>#import "GetBBYprod.h" #import "MyViewController.h" static NSString *kAblue = @"A_blue.png"; static NSString *kBblue = @"B_blue.png"; static NSString *kCblue = @"C_blue.png"; @implementation GetBBYprod @synthesize vc; -(id)init { if (self = [super init]) { vc = [[MyViewController alloc] init]; } return self; } -(void)connectionDidFinishLoading:(NSURLConnection *)conn { NSString *bbyProdString = [[NSString alloc] initWithData:bbyProdData encoding:NSUTF8StringEncoding]; NSString *server = [bbyProdString substringToIndex:2]; if ([server isEqualToString:@"rb"]) { [vc setAlight:kBblue]; } } </code></pre> <p>So that sends kBblue to the method setAlight in my MyViewController class. (The value of kBblue is "B_blue.png".</p> <p>So in my MyViewController class, setAlight method:</p> <pre><code>-(id)init { if (self = [super init]) { aImage = [[UIImageView alloc] init]; bImage = [[UIImageView alloc] init]; cImage = [[UIImageView alloc] init]; } return self; } -(void)setAlight:(NSString *)aValue { NSLog(@"image name: %@", aValue); [aImage setImage:[UIImage imageNamed:aValue]]; } </code></pre> <p>That will successfully log "image name: B_blue.png" so I know the data is being passed and the method is being called. But it won't set the image in the aImage UIImageView. Why?</p> <p><strong>EDIT</strong></p> <ul> <li>I'm using a xib and the imageView is assigned a default image.</li> <li>All of my connections are connected in the xib and they all look correct.</li> <li>There is no whitespace in the string that I'm passing.</li> <li>I can tell that the image hasn't been set because it will be very obvious to me when it's set correctly.</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload