【UIKit】页面视图间的切换Alert,Sheet等使用
2014-04-12 11:28
549 查看
代码
【Alert】
代码:
1.加入协议
<UIAlertViewDelegate,UIActionSheetDelegate>
2.
-(IBAction)btnShowAlertView:(id)sender { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"标题" message:@"对话框的内容" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:@"其他1",@"其他2",nil]; [alert show]; [alert release]; }
3.如何获取到点击按钮的tag
#pragma mark - UIAlertViewDelegate可以获取到所按的按钮的index -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"actionSheet buttonIndex = %i", buttonIndex); }
【sheet】
1.加入协议
<UIAlertViewDelegate,UIActionSheetDelegate>
2.
-(IBAction)btnShowActionSheet:(id)sender { UIActionSheet *actions=[[UIActionSheet alloc]initWithTitle:@"标题" delegate:self cancelButtonTitle:@"关闭" destructiveButtonTitle:nil otherButtonTitles:@"其他1",@"其他2", nil]; [actions showInView:self.view]; [actions release]; }
3.获取到sheet点击按钮的index
#pragma mark - UIActionSheetDelegate - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { NSLog(@"actionSheet buttonIndex = %i", buttonIndex); }
【SVStatusHUD】素材 代码
-(IBAction)btnStatusHUD:(id)sender { [SVStatusHUD showSuccessWithStatus:@"授权已过期!"]; }
操作步骤:
1.在.m中引用
#import "SVStatusHUD.h"
2.加入代码
-(IBAction)btnStatusHUD:(id)sender { [SVStatusHUD showSuccessWithStatus:@"授权已过期!"]; }
【Xib页面间的切换】
-(IBAction)btnRegisterClicked:(id)sender { if(secondViewController==nil) { secondViewController=[[SecondViewController alloc]initWithNibName:nil bundle:nil]; } [self.view.superview addSubview:secondViewController.view]; [self.view removeFromSuperview]; }
【嵌套的Alert】
#pragma mark -循环提问 -(IBAction)btnShowAlertView:(id)sender { UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"标题" message:@"对话框的内容" delegate:self cancelButtonTitle:@"关闭" otherButtonTitles:@"其他1",@"其他2",nil]; alert.tag=1; // 【使用tag值进行嵌套跳出】 [alert show]; [alert release]; } #pragma mark - UIAlertViewDelegate -(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if(alertView.tag==1) // 【判断如果tag==1,那么就继续第二层,然后在本方法中设置tag为2,当再次进入此循环后,tag!=1就可以跳出循环了】 { NSLog(@"actionSheet buttonIndex = %i", buttonIndex); UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"标题2" message:@"对话框的内容2" delegate:self cancelButtonTitle:@"关闭2" otherButtonTitles:@"第二层2",@"第二层1",nil]; alert.tag=2; [alert show]; [alert release]; } else { NSLog(@"actionSheet buttonIndex = %i", buttonIndex); } }
相关文章推荐
- 使用ViewFlipper实现页面自动切换
- ViewPager的使用方法(实现左右滑动切换页面)
- Android使用ActionBar和ViewPager切换页面
- ajax(即使用了UpdatePanel控件的页面)的alert
- iOS导航栏UINavigationController的使用和页面之间的切换(两种实现)
- IOS学习之Tab Bar的使用和视图切换
- Asp.net 2.0 自定义控件开发专题[详细探讨页面状态(视图状态和控件状态)机制及其使用场景](示例代码下载)
- setContentView+LayoutInflater=完美切换页面(两者一定要同时使用,setContentView提高切换页面速度必看)setContentView的秘密----续上
- C#.NET常见问题(FAQ)-使用SharpDevelop开发 如何切换设计视图和代码视图
- Android使用两个Activity页面切换… 分类: Android开发 2014-05-30 10:55 65人阅读 评论(0) 收藏
- 使用AngularJS实现可伸缩的页面切换的方法
- Android视图切换动画库SwitchLayout的简单使用
- 自定义视图之ActionSheet中使用PickerView
- Asp.net 2.0 自定义控件开发专题[详细探讨页面状态(视图状态和控件状态)机制及其使用场景](示例代码下载)
- C#.NET常见问题(FAQ)-使用SharpDevelop开发 如何切换设计视图和代码视图
- ionic2 使用tabs+slides实现滑动切换页面效果
- (转) iOS学习之UINavigationController详解与使用(二)页面切换和segmentedController
- Asp.net 2.0 自定义控件开发专题[详细探讨页面状态(视图状态和控件状态)机制及其使用场景](示例代码下载)
- iOS学习之Tab Bar的使用和视图切换
- AD10 层相关操作(视图从底层往顶层看 层切换和层切换的快捷键的使用 阻焊层solder与助悍层paste 增加机械层)