アニメーションについてはまったく考えがありません。提案されたかなりの数のアニメーションを使用しましたが、要件に従って何も機能しませんでした。単語の長さに従って一連の UIButtons が表示されています。つまり、各ボタンには文字が含まれています。その単語の.だから私がやりたいのは、単語自体を配置しながら、ボタンを右から来て、言及された位置(座標)に戻すことです.単語の長さに等しいボタンを作成する方法は次のとおりです.
-(void)buttonsCreation:(int)noOfButtons
{
for (UIView *view in self.view.subviews)
{
if ([view isKindOfClass:[UIButton class]])
{
if (view.tag >=100)
{
[view removeFromSuperview];
}
}
}
NSMutableArray *charactersArray = [NSMutableArray array];
self.wordButtons = [[NSMutableArray alloc]initWithCapacity:30];
BOOL record = NO;
int randomNumber;
for (int i=0; [charactersArray count] < jumbledWord.length; i++) //Loop for generate different random values
{
randomNumber = arc4random() % jumbledWord.length;//generating random number
if(i==0)
{
[charactersArray addObject:[NSNumber numberWithInt:randomNumber]];
}
else
{
for (int j=0; j<= [charactersArray count]-1; j++)
{
if (randomNumber ==[[charactersArray objectAtIndex:j] intValue])
record = YES;
}
if (record == YES)
record = NO;
else
[charactersArray addObject:[NSNumber numberWithInt:randomNumber]];
}
}
int arrayValue;
float x = 60.0;
float y = 50.0;
for(int i=0;i<[jumbledWord length];i++)
{
if(i>=0 && i<10)
{
arrayValue = [[charactersArray objectAtIndex:i] intValue];
x = x + 37;
UIButton *characterButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
characterButton.frame = CGRectMake(x,175.0, 35.0, 35.0);
[wordButtons addObject:characterButton];
NSString *characterValue = [NSString stringWithFormat:@"%c",[jumbledWord characterAtIndex:arrayValue]];
[characterButton setTitle:characterValue forState:UIControlStateNormal];
[characterButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
if (arrayValue==0)
{
arrayValue = 100;
}
[characterButton setTag:arrayValue*100];
[self.view addSubview:characterButton];
}
else if(i>=10 && i<20)
{
arrayValue = [[charactersArray objectAtIndex:i] intValue];
y = y + 37;
UIButton *characterButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
characterButton.frame = CGRectMake(y,200.0, 35.0, 35.0);
[wordButtons addObject:characterButton];
NSString *characterValue = [NSString stringWithFormat:@"%c",[jumbledWord characterAtIndex:arrayValue]];
[characterButton setTitle:characterValue forState:UIControlStateNormal];
[characterButton addTarget:self action:@selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
if (arrayValue==0)
{
arrayValue = 100;
}
[characterButton setTag:arrayValue*100];
[self.view addSubview:characterButton];
}
}
}
PS -*オフ ポスト*: 以下のコードを使用して、一連のボタンをビューから閉じてから、次の一連のボタン、つまり次の単語を表示しています。
for (UIView *view in self.view.subviews)
{
if ([view isKindOfClass:[UIButton class]])
{
if (view.tag >=100)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.30f];
view.transform =
CGAffineTransformMakeTranslation(
view.frame.origin.x,
480.0f + (view.frame.size.height/2) // move the whole view offscreen
);
[UIView commitAnimations];
}
}
}
誰かが私を案内してくれませんか、ありがとう:)