UIview
(TestView)にimageviewを追加するコードを書きました。そして、画像を追加するためのタッチデリゲートメソッドで、ビューの任意の場所をタップすると、画像がUIview
(testview)に追加され、この画像は可変配列に追加されます。 appdelegate クラスで宣言されています。別の配列には、その画像のフレームが含まれています。上記のプロセスは、画像を追加するためにタップするたびに行われます。削除プロセスでは、可変配列の画像と関連するインデックスを削除します。任意の画像をビュー内の任意の場所に移動することもできます。
しかし、ビルドは非常に遅く、ipad デバイスでひびが入っており、次のエラーが表示されます:-
Program received signal: “0”. Data Formatters temporarily unavailable, will re-try after a 'continue'. (Unknown error loading shared library "/Developer/usr/lib/libXcodeDebuggerSupport.dylib")
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
CGPoint point_Temp = [[[event allTouches] anyObject] locationInView:TestView];
point_TouchStart = [[[event allTouches] anyObject] locationInView:TestView];
bool_ValidtouchFound = NO;
for(int int_Temp=0; int_Temp < [appDelegate_iPad.marry_ContainsRect count]; int_Temp+=1)
{
NSValue *val_Temp = [appDelegate_iPad.marry_ContainsRect objectAtIndex:int_Temp];
CGRect rect_Temp = [val_Temp CGRectValue];
NSLog(@"rect_Temp = %f, %f",rect_Temp.origin.x,rect_Temp.origin.y);
if(CGRectContainsPoint(rect_Temp, point_Temp))
{
bool_ValidtouchFound = YES;
int_TextIndex = int_Temp;
imgview_Temp = [appDelegate_iPad.marry_ContainsImages objectAtIndex:int_TextIndex];
for(UIImageView *imgview_Transparent in [imgview_Temp subviews])
imgview_Dummy = imgview_Transparent;
[imgview_Dummy setFrame:CGRectMake(0.0, 0.0, imgview_Temp.frame.size.width, imgview_Temp.frame.size.height)];
[imgview_Dummy setBackgroundColor:[UIColor clearColor]];
[imgview_Temp addSubview:imgview_Dummy];
if([appDelegate_iPad.marry_ContainsImages count] > int_Temp)
imgview_Text = [appDelegate_iPad.marry_ContainsImages objectAtIndex:int_Temp];
break;
}
}
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if(bool_IsTextReadyToMove
&& ![appDelegate_iPad.CurrentFeatureStatus isEqualToString:@"Pencil"]
&& ![appDelegate_iPad.CurrentFeatureStatus isEqualToString:@"Eraser"]
&& ![appDelegate_iPad.CurrentFeatureStatus isEqualToString:@"Brush"])
{
float float_difx = [[touches anyObject] locationInView:imgview_Text].x - [[touches anyObject] previousLocationInView:imgview_Text].x;
float float_dify = [[touches anyObject] locationInView:imgview_Text].y - [[touches anyObject] previousLocationInView:imgview_Text].y;
CGAffineTransform transform_NewTemp = CGAffineTransformTranslate(imgview_Text.transform, float_difx, float_dify);
imgview_Text.transform = transform_NewTemp;
}
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
if(bool_ValidtouchFound)
{
if(appDelegate_iPad.bool_IsTextReadyToDraw)// code to draw images
{
UIImage *img_Temp = [UIImage imageNamed:appDelegate_iPad.str_ImageName];
UIImageView *imgview_DrawText = [[UIImageView alloc]initWithImage:img_Temp ];
CGRect rect_Temp = CGRectMake(point_Temp.x, point_Temp.y, img_Temp.size.width, img_Temp.size.height);
[imgview_DrawText setFrame:rect_Temp];
[imgview_DrawText setTag:101];
UIImageView *imgview_SubView = [[UIImageView alloc]initWithFrame:CGRectMake(0.0, 0.0, img_Temp.size.width, img_Temp.size.height)];
[imgview_SubView setBackgroundColor:[UIColor clearColor]];
[imgview_DrawText addSubview:imgview_SubView];
// [imgview_SubView sendSubviewToBack:imgview_DrawText];
// [imgview_DrawText bringSubviewToFront:imgview_SubView];
// imgview_DrawText.layer.borderColor = [[UIColor blackColor] CGColor];
// imgview_DrawText.layer.borderWidth =0.6f;
[appDelegate_iPad.marry_ContainsRect addObject:[NSValue valueWithCGRect:rect_Temp]];
[appDelegate_iPad.marry_ContainsImages addObject:imgview_DrawText];
[TestView addSubview:imgview_DrawText];
if(imgview_DrawText)
{
[imgview_DrawText release];
imgview_DrawText = nil;
}
if(imgview_SubView)
{
[imgview_SubView release];
imgview_SubView = nil;
}
if(img_Temp)
img_Temp = nil;
NSLog(@"Array Count After Addition = %d",[appDelegate_iPad.marry_ContainsRect count]);
}
else // Code for Delete images
{
for(int int_Temp=0; int_Temp < [appDelegate_iPad.marry_ContainsRect count]; int_Temp+=1)
{
NSValue *val_Temp = [appDelegate_iPad.marry_ContainsRect objectAtIndex:int_Temp];
CGRect rect_Temp = [val_Temp CGRectValue];
if(CGRectContainsPoint(rect_Temp, point_Temp))
{
UIImageView *imgview_RemoveText = [appDelegate_iPad.marry_ContainsImages objectAtIndex:int_Temp];
[imgview_RemoveText removeFromSuperview];
imgview_RemoveText = nil;
[appDelegate_iPad.marry_ContainsRect removeObjectAtIndex:int_Temp];
[appDelegate_iPad.marry_ContainsImages removeObjectAtIndex:int_Temp];
break;
}
}
NSLog(@"Array Count After Deletion = %d",[appDelegate_iPad.marry_ContainsRect count]);
}
}
}
だから、助けてください。ありがとう