하나의 이미지에서 3 장의 이미지가 3 개 (크롭 핑으로) 있지만 이미지 뷰의 이동을 관리하는 방법은 내가 다른 객체를 선언하거나 다른 방법으로 선언해야한다는 것입니다 ... 가능합니다 .... 배열을 사용하여 이러한 많은 이미지를 관리하십시오. 친구를 도와주세요UIImageView로 재생 하시겠습니까?
우리는 개체의 배열로 할 수있는 ...?
- (void)viewDidLoad {
UIImage *img = [UIImage imageNamed:@"3.jpg"];
for(int i = 0;i < 3;i++)
{
for (int j = 0; j < 3 ; j++)
[self SetImagePeces:i :j];
}
[super viewDidLoad];
}
-(void) SetImagePeces:(int)col:(int)row
{
UIImage *img = [UIImage imageNamed:@"3.jpg"];
img1 = [[UIImageView alloc] init];
img1.frame = CGRectMake(0 + 235 * col, 0 + 235 * row, 233, 233);
img1.tag = row;
img1.userInteractionEnabled = YES;
CGRect clippedRect = CGRectMake(0 + 233 * col,700 - 233 * row, 233, 233);
UIImage *imgV = [self imageByCropping:img toRect:clippedRect];
img1.image = imgV;
[self.view addSubview:img1];
[img1 release];
}
UPDATE : 아직
가 지금은 700 * 700 크기의 이미지를 실험
하지만 어떻게 우리의 크기는 이미지의 크기를 결합하는 ..
** 터치 이벤트 :: **
여기-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
if (touch.view == img2) {
if (c2 == 0) {
tempImg = img2.image;
[flag replaceObjectAtIndex:1 withObject:@"1"];
c2++;
}
else {
for(int j=0;j<9;j++)
{
if(j==1)
{[flag replaceObjectAtIndex:j withObject:@"0"];}
else
{
int a=[[flag objectAtIndex:j]integerValue];
if (a==1) {
img3.image=img2.image;
[flag replaceObjectAtIndex:j withObject:@"0"];
}
}
}
img2.image = tempImg;
c2 = 0;
}
}
if (touch.view == img3) {
if (c2 == 0) {
tempImg = img3.image;
[flag replaceObjectAtIndex:2 withObject:@"1"];
c2++;
}
else {
for(int j=0;j<9;j++)
{
if(j==2)
{[flag replaceObjectAtIndex:j withObject:@"0"];}
else
{
int a=[[flag objectAtIndex:j]integerValue];
if (a==1) {
img2.image=img3.image;
[flag replaceObjectAtIndex:j withObject:@"0"];
}
}
}
img3.image = tempImg;
c2 = 0;
}
}
}
내가 터치에 방법이 너무 만이 개 이미지를 구현 시작 이미지를 교환하지만 너무 어려운 더 많은 이미지를 옴하는 것입니다
고지 사전
내가 pls 위의 코드를 추가 ... 제 제안을 ... 난 무작위로 터치하여보다 이미지를 설정해야 ... – AJPatel
당신이 지금까지 내가이 별도의 UIImageview 개체를 사용하여 시도해 주셔서 감사합니다 터치 이벤트를 사용하십시오. 보자. 나에게 도움이 될지도 모른다. ... – AJPatel
당신은 환영한다. :) – AechoLiu