1.Alert View 一般给用户提供告警信息。
如:
UIAlertView *alert =[[UIAlertView alloc] initWithTitle:nil message:@"相机不能用" delegate:nil cancelButtonTitle:@"关闭" otherButtonTitles:nil];
[alert show];
[alert release];
2.Action Sheets用来提示用户在可能的几种操纵中作出选择,也可以用来在用户将要进行不可逆的危险操作时,给用户确认或取消的机会。
创建Action Sheets 需要3个步骤:
1.指定相应的ViewController遵循UIActionSheetDelegate协议
2.实现相应的delegation方法
3.创建并显示Action Sheet是给用户选项,所以按钮数目肯定要大于一个。另外,按钮上显示的文字应该能够明确标识按钮的功能。
- (IBAction)loadActionSheet:(id)sender
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Action Sheet窗口"
delegate:self
cancelButtonTitle:@"关闭"
destructiveButtonTitle:nil
otherButtonTitles:@"显示Alert窗口",
@"do sth", @"do sth", nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
//UIActionSheetDelegate协议的方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex)
{
case 0:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert窗口"
message:@"内容 btn1"
delegate:self
cancelButtonTitle:@"确认"
otherButtonTitles:nil];
[alert show];
[alert release];
}
break;
case 1:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert窗口"
message:@"内容 btn2"
delegate:self
cancelButtonTitle:@"确认"
otherButtonTitles:nil];
[alert show];
[alert release];
}
break;
case 2:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert窗口"
message:@"内容 btn3"
delegate:self
cancelButtonTitle:@"确认"
otherButtonTitles:nil];
[alert show];
[alert release];
}
break;
case 3:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"关闭alert窗口"
message:@"内容 关闭"
delegate:self
cancelButtonTitle:@"确认"
otherButtonTitles:nil];
[alert show];
[alert release];
}
break;
default:
break;
}
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Action Sheet窗口"
delegate:self
cancelButtonTitle:@"关闭"
destructiveButtonTitle:nil
otherButtonTitles:@"显示Alert窗口",
@"do sth", @"do sth", nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
//UIActionSheetDelegate协议的方法
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
switch (buttonIndex)
{
case 0:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert窗口"
message:@"内容 btn1"
delegate:self
cancelButtonTitle:@"确认"
otherButtonTitles:nil];
[alert show];
[alert release];
}
break;
case 1:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert窗口"
message:@"内容 btn2"
delegate:self
cancelButtonTitle:@"确认"
otherButtonTitles:nil];
[alert show];
[alert release];
}
break;
case 2:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"alert窗口"
message:@"内容 btn3"
delegate:self
cancelButtonTitle:@"确认"
otherButtonTitles:nil];
[alert show];
[alert release];
}
break;
case 3:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"关闭alert窗口"
message:@"内容 关闭"
delegate:self
cancelButtonTitle:@"确认"
otherButtonTitles:nil];
[alert show];
[alert release];
}
break;
default:
break;
}
}
3.Modal Views 是弹出的相对独立的用户界面,在这个界面中用户可以完成一些相对独立于软件的事物,完成后可以退出Modal View返回软件界面。比较典型的例子包括在软件中发送邮件、从相片库中选取照片等。
设计使用Mdal View的时候需要注意几点:首先Modal View一般都是全屏,其次Modal View应该提供明确的让用户退出Modal View的按钮,一般做法是在上面显示导航条。
[self presentModalViewController:picker animated:YES];
Modal View 示例参照:http://www.cnblogs.com/hanjun/archive/2012/11/22/2783266.html
致力于ios开发