2010-11-15 65 views
0

我爲我的應用程序創建了UIAlertview,如下所示。UIAlertView顯示爲緩慢

NSString *[email protected]"\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像幻燈片格式一樣緩慢?

+0

確定。感謝您的建議 – Velmurugan 2010-11-15 16:36:53

回答

0

我得到的答案類似的幻燈片預覽...

 -(void)tableView:(UITableView *)tableView1 didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 
     NSString *[email protected]"\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]; 
     } 
+0

請格式化您的代碼。有一個按鈕和一切,讓你這樣做... – 2010-11-25 11:56:55

+0

嗨。感謝您的指揮。 – Velmurugan 2010-11-25 12:03:36