我在中添加图像
NSMutableArray
比我把它转换成
NSData
而agaun我将该图像存储在其他
NSMutableArray(NS可变阵列)
。但是当我转换回给我错误的图像时
我的代码是
NSData *Puzzleimage;
PuzzleImg = [[NSMutableArray alloc] init];
TriangleImg = [[NSMutableArray alloc] init];
[PuzzleImg addObject:[UIImage imageNamed:@"Triangle_1.png"]];
[PuzzleImg addObject:[UIImage imageNamed:@"Triangle_2.png"]];
[PuzzleImg addObject:[UIImage imageNamed:@"Triangle_3.png"]];
[PuzzleImg addObject:[UIImage imageNamed:@"Triangle_4.png"]];
[PuzzleImg addObject:[UIImage imageNamed:@"Triangle_5.png"]];
for (int l=0; l<[PuzzleImg count]; l++) {
Puzzleimage = UIImagePNGRepresentation([PuzzleImg objectAtIndex:l]);
[TriangleImg addObject:Puzzleimage];
在滚动视图中检索
CGRect scrollViewFrame = CGRectMake(10, 60, 300, 350);
PuzzleList = [[UIScrollView alloc] initWithFrame:scrollViewFrame];
[self.view addSubview:PuzzleList];
int y1=10;
int y2=10;
if ([PuzzleImg count] >0)
{
for(int i=0;i<[PuzzleImg count];i++)
{
UIImage *SolImg = [[UIImage alloc] initWithData:[PuzzleImg objectAtIndex:i]];
UIButton *btn =[[UIButton alloc]initWithFrame:CGRectMake(10, y1, 100, 100)];
[btn setBackgroundImage:SolImg forState:UIControlStateNormal];
btn.tag = i;
[btn addTarget:self action:@selector(SelectPuzzleButtonClick:) forControlEvents:UIControlEventTouchUpInside];
[PuzzleList addSubview:btn];
y1=y1+110;
}
}
错误为
*错误显示在Line::UIImage上
SolImg=[[UIImage alloc]initWithData:[PuzzleImg objectAtIndex:i]];
-[UIImage length]:无法识别的选择器发送到实例0xa1bc690
2013-04-10 10:41:47.292创意逻辑〔2791:1a003〕
*由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:“-[UIIImage length]:无法识别的选择器发送到实例0xa1bc690”
*
首次抛出调用堆栈:
(0x2612012 0x1422e7e 0x269d4bd 0x2601bbc 0x260194e 0x4cf1b2 0x8c1f3 0xc1d7 0xaac3 0xa532 0x44b817 0x44b882 0x44bb2a 0x462ef5 0x462fdb 0x463286 0x463381 0x463eab 0x4644a3 0x464098 0xe255 0x1436705 0x36d920 0x36d8b8 0x42e671 0x42ebcf 0x42dd38 0x39d33f 0x39d552 0x37b3aa 0x36ccf8 0x28fedf9 0x28fead0 0x2587bf5 0x2587962 0x25b8b b6 0x25b7f44 0x25b7 e1b 0x28fd7e3 0x28fd668 0x36a65c 0x2022 0x1f55)
libc++abi.dylib:调用terminate引发异常