我使用以下代码来显示一个警告框:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info" message:@"My Message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];你能告诉我当手机改变方向时如何再次隐藏提示框吗?
发布于 2011-01-28 20:02:36
首先,您必须在您的界面中保存对警报的引用。
@interface MyViewController : UIViewController {
UIAlertView *alert;
}
@property (nonatomic, retain) IBOutlet UIAlertView *alert;创建警报时,您将使用
self.alert = [[[UIAlertView alloc] initWithTitle:@"Info" message:@"My Message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease];
[alert show]; 然后,您必须添加另一个方法didRotateFromInterfaceOrientation:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[alert dismissWithClickedButtonIndex:[alert cancelButtonIndex] animated:YES];
self.alert = nil;
}https://stackoverflow.com/questions/4827710
复制相似问题