Ios 入门 ----基本的控件 (一)
来源:互联网 发布:沈晓海花姑子知乎 编辑:程序博客网 时间:2024/05/17 23:06
1.UIAlertView的实现:
效果如下图:
2.UIActionSheet 的实现
UIActionSheet和UIAlertView的区别 都是用于给用户提示操作 而UIActionSheet是从底部弹出 当用户有危险操作时用来提示 例如用户删除某个文件就可以用UIActionSheet提示用户是否确认删除
首先.h文件要实现UIActionSheetDelegate 并且实现Delegate中的方法:
actionSheet:didDismissWithButtonIndex 方法
这个方法当你点击摸个按钮时会自动触发 上面代码中点击cancel这个按钮时 文字将变成空;
效果如图:
3.两个等待控件UIActionIndicatorView 和 UIProgressView
我们来做一个小程序来实现他俩的功能
需求:点击按钮 进度条开始前进 进度条走完弹出 安装对话框 点击安装 UIActionIndicatorView开始旋转
界面如下:
.h代码
@interface seek : UIViewController <UIActionSheetDelegate> {
UIActivityIndicatorView *seekbar;
UIProgressView *probar;
NSTimer * time;
}
@property (nonatomic, retain) IBOutlet UIActivityIndicatorView *seekbar;
@property (nonatomic, retain) IBOutlet UIProgressView *probar;
@property (nonatomic, retain)NSTimer * time;
- (IBAction)downLond:(id)sender;
@end
.m代码
- (IBAction)downLond:(id)sender {
probar.progress=0.0;
time=[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateinstall) userInfo:nil repeats:YES];
}
-(void)updateinstall{
probar.progress=probar.progress+0.1;
if(probar.progress==1.0){
[time invalidate];
UIActionSheet * actionSheet =[[UIActionSheet alloc]initWithTitle:@"Install" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Install" otherButtonTitles:nil, nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
}
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
if (buttonIndex==[actionSheet destructiveButtonIndex]) {
if ([seekbar isAnimating]) {
[seekbar stopAnimating];
}else {
[seekbar startAnimating];
}
}
}
NSTimer是可以隐式地启动一个线程,
scheduledTimerWithTimeInterval指定线程要休眠
多少时间调用一次,selector所指定的方法updateinstall
运行效果如下:
- Ios 入门 ----基本的控件 (一)
- Ios 入门 ----基本的控件
- Ios 入门 ----基本的控件 (二)
- Ios 入门 ----基本的控件 (三)
- iOS基本控件<一>
- iOS 入门之UI基本控件
- iOS---基本的UI控件
- iOS入门-基础控件总结(一)
- 基本的Web控件一
- Cocoa Touch 入门记——《精通 iOS 开发》学习心得(1) [基本控件的交互]
- 安卓入门一之基本控件使用
- IOS的基本控件的使用-UILabel
- IOS的基本控件的使用-UIButton
- IOS的基本控件的使用-UIScrollView
- iOS开发最基本控件的使用
- IOS中UI控件的基本使用
- iOS中的基本 UI 控件的使用
- ios开发及控件的基本认识
- onmouseover与onmouseout事件处理器
- Objective-C 入门(七)协议 protocol(JAVA中的接口)
- /proc/pid进程相关说明
- [JSOI2007]文本生成器
- sencha-touch-1.1 动态绑定selectfield
- Ios 入门 ----基本的控件 (一)
- C# 获取网页标题title、keywords、description 的代码(winform)
- Ios 入门 ----基本的控件 (二)
- jsp分页原理
- 关注CRM选型的加减法
- 网站加速--服务器编写篇
- 关于本博客
- 在程序中如何以dp为单位设置控件的宽和高
- 获取checkbox选中后表格里的值