UIAlertView点击确定后,如何跳转到storyboard中创建的另一个UIViewController?
来源:互联网 发布:淘宝联盟的导购推广位 编辑:程序博客网 时间:2024/05/17 04:07
首先要让button所在的ViewController类实现UIAlertView的UIAlertViewDelegate接口,接口中定义了一些方法,其中
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex;
这个方法会在AlertView中的button被点击时被调用,自己可以根据buttonIndex调用不同的方法,
cancel默认是0,所以如果你的alertview只有一个button的话,实现点击确定后的跳转,
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{if (alertView.tag == 1) {[self segue];}}
其中tag相当于alertview的标签,可以通过[alertview setTag:]方法设置,用来区别同一ViewController中的多个AlertView对象,根据我的尝试,似乎默认都为0.
segue为自定义的实现跳转的方法。
-(void)segue{UIStoryboard *mainStoryboard = [UIStoryboardstoryboardWithName:@"Main" bundle:nil];UIViewController *indexViewController = [mainStoryboardinstantiateViewControllerWithIdentifier:@"IndexViewController"];indexViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;[self presentViewController:indexViewController animated:YES completion:^{NSLog(@"登录成功!");}];}
0 0
- UIAlertView点击确定后,如何跳转到storyboard中创建的另一个UIViewController?
- ASP.NET 弹出提示框,点击确定后跳转到另一个页面
- ios中UIAlertView控件的使用,如何确定点击按钮的方式
- 纯代码实现布局的UIViewController跳转到带storyboard布局的UIViewController
- android中如何添加一个监听按钮,点击之后从一个activity跳转到另一个activity
- iOS实现点击按钮,跳转到与mian.storyboard 中与ViewController 关联的页面
- storyboard点击一个按钮跳转到不同的控制器
- 通过StoryBoard创建UIViewController
- 通过StoryBoard创建UIViewController
- 弹出消息框点击确定后跳转
- 在项目中,点击“删除”按钮后,跳转到哪个页面?又该如何设置?
- 代码获取storyboard中定义的UIViewController
- iOS如何从一个Storyboard Push到另一个Storyboard
- storyboard 中如何从一个viewcontroller跳转到另外一个storyboard
- 点击radio跳转到另一个页面
- 点击按钮跳转到另一个页面
- 点击imageview跳转到另一个页面
- 点击imageview跳转到另一个页面
- #AOS应用基础平台# 实现了在用户权限范围内自定义的快捷菜单的导航展示
- Leetcode 198: House Robber
- [Leetcode] 86. Partition List
- Reverse Words in a String ---leetcode 我的java题解
- Sublime Text3打造U盘便携Lua IDE
- UIAlertView点击确定后,如何跳转到storyboard中创建的另一个UIViewController?
- 黑马程序员-JAVASE入门(GUI类)
- lua实现大数运算
- 画线算法 - Bresenham原理及Java实现
- [Leetcode] 87. Scramble String
- [Leetcode] 88. Merge Sorted Array
- LeetCode - Longest Substring Without Repeating Characters
- 黑马程序员-JAVASE入门(多线程)
- 黑马程序员-JAVASE入门(集合)