当我在事件中时,我的图像没有出现在我的 UIImageView 中,在我的 viewDidLoad 中没有问题。
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event
{
if ( event.subtype == UIEventSubtypeMotionShake )
{
int i;
int r;
for ( i = 1 ; i <= 5 ; )
{
r = (arc4random()%NbrCells) + 1;
if (GridCell[r].hidden == NO)
{
// View position.
CGFloat OriginX = GridCell[r].frame.origin.x;
CGFloat OriginY = GridCell[r].frame.origin.y;
CGFloat Height = GridCell[r].frame.size.height;
CGFloat Whidth = GridCell[r].frame.size.width;
[GridCell[r] removeFromSuperview];
GridCell[r] = nil;
GridCell[r] = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]];
GridCell[r].frame = CGRectMake(OriginX, OriginY, Whidth, Height);
GridCell[r].hidden = NO;
[self.MyImage1 addSubview:GridCell[r]];
// [MyArray[r] addObject:[NSNumber numberWithInt:NO]];
i++;
sleep(1);
}
}
NSLog(@"Event stop, number delete = %d", i - 1);
}
if ( [super respondsToSelector:@selector(motionEnded:withEvent:)] )
[super motionEnded:motion withEvent:event];
返回; }
非常感谢。
艾伦10977。