开发者

Need help displaying a UIImage based off selection of UIPicker

 - (void)viewDidLoad
 {
      [super ViewDidLoad];

      [brandTextField addTarget:self action:@selector(showImageFromFilter) forControlEvents:UIControlEventAllEvents];
 }


 - (void)showImageFromFilter
 {
      if (brandTextField.text == @"Awake") 
      {
          NSString * imageString = @"awake_top_purple.png";

          UIImage * womenTopImage = [[UIImage alloc] initWithContentsOfFile:imageString];

          womenTopImageView.image = [[UIImageView alloc] initWithImage:womenTopImage];

         womenTopImageView.contentMode = UIViewContentModeScaleAspectFit;
    }
 }

Here is the general idea of what I am doing.

I have 3 TextFields, each connected to a UIPicker. I have three sets of arrays with values. When I have specific values set I'd like for an image to display below the UITextFields.

This is what I am trying but doesn't seem to be working. Am I on the rig开发者_运维百科ht track or can someone explain how I can get this to work.

Thanks


brandTextField.text == @"Awake"

This will not compare strings.

[brandTextField.text isEqualToString:@"Awake"]

That will compare strings.

Another issue:

Just use

[UIImage imageNamed:@"awake_top_purple.png"];

to get your UIImage, initWithContentsOfFile requires a full path.

You also have a typo on

[super ViewDidLoad]

(lowercase the V).

And I'm not sure that's the best way of hooking up the UIPicker to your showImageFromFilter method.

Have a read through of Apple's sample code and documentation, you'll get a much better feel for how things are supposed to work.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜