iphone – 显示alertview后如何移动到下一个视图控制器
发布时间:2020-12-14 19:00:23 所属栏目:百科 来源:网络整理
导读:我有iPhone,我希望当显示AlertView并且用户按下OK按钮后应该更改该视图但是没有发生. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Thank you" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [a
我有iPhone,我希望当显示AlertView并且用户按下OK按钮后应该更改该视图但是没有发生.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Thank you" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; [alert show]; [alert release]; return; [self moveToView]; -(void)moveToView { MainViewController*targetController=[[MainViewController alloc]init]; [self.navigationController pushViewController:targetController animated:YES]; } 解决方法
请使用UIAlertViewDelegate
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { // Code to move to next view [self moveToView]; } 注意:在接口声明中实现UIAlertViewDelegate.同时在声明UIAlertView时将委托设置为self. 希望这对你有所帮助. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |