Objective c UIPicker[\u NSCFConstantString\u isResizable]上出错:?

Objective c UIPicker[\u NSCFConstantString\u isResizable]上出错:?,objective-c,ios,xcode,uipickerview,Objective C,Ios,Xcode,Uipickerview,UI选择器让我再次陷入困境,我仍在学习UI选择器,因此不确定我是否在这里做了一些根本错误的事情 正在尝试显示行选取器中的图像 错误: ***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[\uu NSCFConstantString\u isressizable]:未识别的选择器已发送到实例0x70fc' ***第一次抛出调用堆栈: 代码如下: #import "Imagepick.h" @interface Imagepick () @e

UI选择器让我再次陷入困境,我仍在学习UI选择器,因此不确定我是否在这里做了一些根本错误的事情

正在尝试显示行选取器中的图像

错误:

***由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[\uu NSCFConstantString\u isressizable]:未识别的选择器已发送到实例0x70fc'
***第一次抛出调用堆栈:

代码如下:

#import "Imagepick.h"

@interface Imagepick ()

@end

@implementation Imagepick
 @synthesize select;
@synthesize imageview;


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

- (void)viewDidLoad
{


   ////arrays & objects
   arrStatus = [[NSArray alloc] initWithObjects:@"pic1",@"pic2",nil];




}
-(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
{
//One column
return 1;
}

-(NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:   (NSInteger)component
 {

return arrStatus.count;


 }

-(NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row    forComponent:(NSInteger)component
 {

  return [arrStatus objectAtIndex:row];

 }
 - (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

{

 [imageview setImage:[arrStatus objectAtIndex:row]]; UIImage *pic1 = [[UIImage alloc]  initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"appstorelogo" ofType:@"png"]];

  [imageview setImage:[arrStatus objectAtIndex:row]]; UIImage *pic2 = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"applogo" ofType:@"png"]];

 }



 - (void)viewDidUnload
{
[self setImageview:nil];
[self select:nil];
[super viewDidUnload];
// Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

*
pic1
pic2
未使用的变量警告,如果相关?

您的问题是[imageview setImage:[arrStatus objectAtIndex:row];您正在尝试使用字符串设置图像

您也没有使用pic1和pic2

您可能需要将imagenames设置为数组,如下所示:

arrStatus = [[NSArray alloc] initWithObjects:@"appstorelogo",@"applogo",nil];
然后将图像设置为

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    UIImage *img = [[UIImage alloc]  initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[arrStatus objectAtIndex:row] ofType:@"png"]];

    [imageview setImage:img]; 
}

您的问题是[imageview setImage:[arrStatus objectAtIndex:row]];您正在尝试使用字符串设置图像

您也没有使用pic1和pic2

您可能需要将imagenames设置为数组,如下所示:

arrStatus = [[NSArray alloc] initWithObjects:@"appstorelogo",@"applogo",nil];
然后将图像设置为

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    UIImage *img = [[UIImage alloc]  initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[arrStatus objectAtIndex:row] ofType:@"png"]];

    [imageview setImage:img]; 
}

+对于OP的问题,我的答案比我的(已删除)准确得多。谢谢!!!!这是一个很好的解决方案。先生,再给你一个+对于OP的问题,我的答案比我的(已删除)准确得多。谢谢!!!!这是一个很好的解决方案。先生,再给你一个!