iPhone起步-2:iPhone常用控件、UIActionSheet、UIAlertView (转)
来源:互联网 发布:免费股票交易软件下载 编辑:程序博客网 时间:2024/04/26 15:13
一、UILabel
二、UIButton
常用事件:Touch Up Inside
三、UITextField
常用属性:
Text:要显示的文本。
Placeholder:指定将要在文本字段中以灰色显示的占位符文本。
Clear When Editing Begins:用户触摸此字段时是否删除字段中的值。
Text Input Traits:文本输入特征。
四、UIImageView
常用属性:
image:指定图像文件
Mode:图像在视图内部的对齐方式以及是否缩放图像以适应视图。选择任何图像缩放的选项都会潜在地增加处理开销,因此最好避开这些选项,并在导入图像之前调整好图像大小。通常Mode属性为Center。
Alpha:图像透明度。一般设置为1.0
Background:该属性继承自UIView,但它不会影响图像视图的外观,请忽略此属性。
Drawing复选框:选中Opaque表示视图后面的任何内容都不应该绘制,并且允许iPhone都绘图方法通过一些优化来加速绘图。
Clear Context Before Drawing:选中它之后,iPhone将使用透明黑色绘制控件覆盖都所有区域,然后才实际绘制控件。考虑到性能问题,并且适用情况很少,通常很少需要选中ClearContext Before Drawing。
Interaction复选框:
User Interaction Enabled:指定用户能否对此对象进行操作。
Multiple Touch:是否能够接收多点触摸事件。
五:UISlider(滑块)
常用属性:Value Changed
示例:
// 将silder的值反映到sliderLabel
- (IBAction) sliderValueChanged: (id)sender
{
UISlider *slider = (UISlider *)sender;
int progressAsInt = (int)(slider.value + 0.5f);
NSString *newText = [[NSStringalloc] initWithFormat:@"%d", progressAsInt];
sliderLabel.text = newText;
[newText release];
}
六:UISwitch(开关)
// 方法setOn:设置开关的状态
- (IBAction) switchChanged: (id)sender
{
UISwitch *whichSwitch = (UISwitch *)sender;
BOOL setting = whichSwitch.on;
[leftSwitch setOn:setting animated:YES];
[rightSwitch setOn:setting animated:YES];
}
七、UISegmentedControl
#define kSegmentIndex_Button 1
- (IBAction) segmentChanged: (id)sender
{
switch ([sender selectedSegmentIndex])
{
case kSegmentIndex_Switches:
leftSwitch.hidden = NO;
rightSwitch.hidden = NO;
doSomethingButton.hidden = YES;
break;
case kSegmentIndex_Button:
leftSwitch.hidden = YES;
rightSwitch.hidden = YES;
doSomethingButton.hidden = NO;
break;
}
}
八、UIActionSheet(操作表)和UIAlertView(警报)
UIActionSheet用于迫使用户在两个或更多选项之间进行选择都模式视图。操作表从屏幕底部弹出,显示一系列按钮供用户选择,用户只有单击了一个按钮后才能继续使用使用应用程序。
UIAlertView(警报)以蓝色圆角矩形都形式出现在屏幕的中部,警报可显示一个或多个按钮。
为了让控制器类充当操作表的委托,控制器类需要遵从UIActionSheetDelegate协议。我们通过在类声明都超类之后都尖括号中添加协议名称来实现。
<UIActionSheetDelegate>
{
// ....
}
- (IBAction) buttonPressed: (id)sender
{
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"Are you sure?"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Yes,I'm sure."
otherButtonTitles:nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
#pragma mark ActionSheet Delegate Methods
- (void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if (buttonIndex != [actionSheet cancelButtonIndex])
{
NSString *text = [[NSString alloc] initWithFormat:@"test alert"];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Something was done."
message:text
delegate:self
cancelButtonTitle:@"OK!"
otherButtonTitles:nil];
[alert show];
[alert release];
[text release];
}
}
//- (void) actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
//{
// NSLog(@"%d",buttonIndex);
//}
示例:
视图有一个UISegmentedControl,"Switches"下有两个UISwitch
"Button"下有一个“Do Something"的UIButton
触摸"Do Something"Button时弹出UIActionSheet
触摸选择"Yes,I'm sure."时弹出 UIAlertView
- iPhone起步-2:iPhone常用控件、UIActionSheet、UIAlertView (转)
- Phone起步-2:iPhone常用控件、UIActionSheet、UIAlertView
- iPhone常用控件、UIActionSheet、UIAlertView
- iPhone常用控件、UIActionSheet、UIAlertView
- [iOS] iPhone常用控件、UIActionSheet、UIAlertView
- IPHONE应用开发 - 开发常用控件:UIActionSheet和UIAlertView学习
- IPHONE应用开发 - 开发常用控件:UIActionSheet和UIAlertView学习
- Iphone之UIAlertView和UIActionSheet
- [转Iphone]UIActionSheet
- [IPhone][SDK][控件]自定义UIAlertView
- iphone开发 UIActionSheet(操作表) 和UIAlertView(警告)的用法
- 【iPhone代码片段之一】UIActionSheet&UIAlertView的应用
- iPhone 开发常用控件
- iphone常用控件
- IOS提示控件UIActionSheet,UIAlertView
- IOS提示控件UIActionSheet,UIAlertView
- iPhone开发之UIActionSheet
- iPhone – UIActionSheet Example
- Rails宝典之第十九式: admin在哪里
- Javascript之文件操作 (IE)
- struts2 :result type的使用
- viusual studio 2008
- 关于Parasoft的中更改C++test的作者计算方式
- iPhone起步-2:iPhone常用控件、UIActionSheet、UIAlertView (转)
- 跟着二厶学编程---JAVA第四章---【变量,对白版】
- 数据库设计中关于表和列的名称
- iPhone起步-1: "Hello,World!" in iPhone Development (转)
- c语言中逗号运算符和逗号表达式
- 解决win7+IE8+开发人员工具不显示问题(附图)
- ADO数据库编程入门
- 打印VO的SQL语句和绑定参数的代码片断
- 嵌入式新手指南