UIAlertView显示缓慢

时间:2010-11-15 09:36:08

标签: iphone

我为我的应用程序创建了UIAlertview,如下所示。

NSString *message=@"\n\n\n\n\n\n\n\n\n";
UIALertView *successAlert = [[UIAlertView alloc] initWithTitle:@"title" message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(12, 8, 260, 274)];
NSData *mydata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[images objectAtIndex:indexPath.row]]];
UIImage *bkgImg = [[UIImage alloc] initWithData:mydata ];
[imageView setImage:bkgImg];
[bkgImg release];
[mydata release];
[successAlert addSubview:imageView];
[imageView release];
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
UIImage* myButtonImage = [UIImage imageNamed:@"Close.png"];
[button setImage:myButtonImage forState:UIControlStateNormal];
[button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
[button setTitle:@"Show View" forState:UIControlStateNormal];
button.frame = CGRectMake(255.0, 10.0, 15.0, 15.0);
[successAlert addSubview:button];
[successAlert show];

但是上面的代码显示警报为快速移动,它会突然显示。现在我需要像弹出窗口一样缓慢地显示警报视图。

如何以幻灯片格式缓慢显示UIAlertview?

1 个答案:

答案 0 :(得分:0)

我得到了像幻灯片预览一样的答案......

      -(void)tableView:(UITableView *)tableView1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
       NSString *message=@"\n\n\n\n\n\n\n\n\n";
       UIALertView *successAlert = [[UIAlertView alloc] initWithTitle:@"title" message:message delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
      UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(12, 8, 260, 274)];
      NSData *mydata = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:[images objectAtIndex:indexPath.row]]];
      UIImage *bkgImg = [[UIImage alloc] initWithData:mydata ];
      [imageView setImage:bkgImg];
      [bkgImg release];
      [mydata release];
      [successAlert addSubview:imageView];
      [imageView release];
      UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
      UIImage* myButtonImage = [UIImage imageNamed:@"Close.png"];
      [button setImage:myButtonImage forState:UIControlStateNormal];
      [button addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
      [button setTitle:@"Show View" forState:UIControlStateNormal];
      button.frame = CGRectMake(255.0, 10.0, 15.0, 15.0);
      [successAlert addSubview:button];
      [successAlert show];
      [self pulse];
      }


         float pulsesteps[3] = { 1.8, 1/15.0, 1/7.5 };

       -(void) pulse 
       {
        successAlert.transform = CGAffineTransformMakeScale(0.1,0.1);
        [UIView beginAnimations:nil context:nil];
        [UIView setAnimationDuration:pulsesteps[0]];
        [UIView setAnimationDelegate:self];
        [UIView setAnimationDidStopSelector:@selector(pulseGrowAnimationDidStop:finished:context:)];
        successAlert.transform = CGAffineTransformMakeScale(1.1, 1.1);
        [UIView commitAnimations];
       }
       -(void)pulseGrowAnimationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:pulsesteps[1]];
        [UIView setAnimationDelegate:self];
                [UIView setAnimationDidStopSelector:@selector(pulseShrinkAnimationDidStop:finished:context:)];
        successAlert.transform = CGAffineTransformMakeScale(1.0, 1.0);
        [UIView commitAnimations];
      }           
       -(void)pulseShrinkAnimationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
        [UIView beginAnimations:nil context:NULL];
        [UIView setAnimationDuration:pulsesteps[2]];
        successAlert.transform = CGAffineTransformIdentity;
        [UIView commitAnimations];
      }