Gavin.han

致力于移动开发 技术改变生活
随笔 - 133, 文章 - 0, 评论 - 46, 阅读 - 42万

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

ios UI设计与开发 弹出式视图

Posted on   gavin.han  阅读(2670)  评论(0编辑  收藏  举报

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;
    }
复制代码

 

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 

 

编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
点击右上角即可分享
微信分享提示