【iOS】App仿写--管理系统

这篇具有很好参考价值的文章主要介绍了【iOS】App仿写--管理系统。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。


前言

在日常生活中,如果用文字来记述与管理我们数据会十分麻烦,并且人工成本较高,这里笔者给出一种管理系统的模版,供大家借鉴,可凭借实际需求来创建所需要的管理系统

在先前C语言的学习过程中,笔者已经仿写过了学生管理系统,不过C语言的学生管理系统是没有UI的,所有功能都在控制台中实现,现用OC来仿写我们的管理系统


一、账号界面

这里的账号界面与3GShare大同小异,不再详细讲述,详见iOS–3GShare
唯一不同的就是在管理系统中使用了自定义字体,详见iOS自定义字体
【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c


二、功能界面

登录成功后首先出现的是我们功能界面,并且在功能界面显示了我们的人员信息
【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c
这里笔者使用了TableView来显示各项数据
【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c
在上面的第一行信息栏笔者使用了UILabel,这样可以根据自己的需要来更改管理系统需要管理的数据
【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c


三、添加功能

首先来看我们功能的实效效果
【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c
笔者的管理系统允许不同班级的有重名,但相同的鸡圈中不能有重名,同时成绩的区间需要在0-100之间,不能在这个区间之外,接下来放出具体实现代码:

- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)confirm {
    NSString *s1 = _textField1.text;
    NSString *s2 = _textField2.text;
    NSString *s3 = _textField3.text;
    
    int boo1 = 0;
    int boo2 = 0;
    int boo3 = 0;
    
    for (int i = 0; i < _arrayName.count; i++) {
        if ([s1 isEqualToString:_arrayName[i]] && [s2 isEqualToString:_arrayClass[i]]) {
            boo1 = 1;
            boo2 = 1;
            break;
        }
        if (s3.integerValue < 0 || s3.integerValue > 100 || s2.integerValue < 0 || s2.integerValue > 10) {
            boo3 = 1;
            break;
        }
    }
    

    if (s1.length > 0 && s2.length > 0 && s3.length > 0){
        _textField1.text = @"";
        _textField2.text = @"";
        _textField3.text = @"";
        if (boo1 == 1 && boo2 == 1) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"此只因已存在" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else if (boo3 == 1) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入信息不合法" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else {
            [_arrayName addObject:s1];
            [_arrayClass addObject:s2];
            [_arrayScore addObject:s3];
            [self.delegate addName:_arrayName addClass:_arrayClass addScore:_arrayScore];
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"添加成功" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [self dismissViewControllerAnimated:YES completion:nil];
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        }
    } else {
        self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入不能为空" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [self.alert addAction:confirmAction];
        [self presentViewController:self.alert animated:YES completion:nil];
    }
}

这里需要注意的是添加成功之后需要将新的数据回传给功能界面,然后接着进行下一步操作


四、删除功能

【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c
笔者的删除功能是需要给出要删除的名字与其对应的鸡圈,这是因为不同鸡圈中可能存在重名
具体实现代码:

- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)confirm {
    NSString *s1 = _textField1.text;
    NSString *s2 = _textField2.text;
    
    int boo1 = 0;
    int boo2 = 0;
    
    int t = 0;
    
    for (int i = 0; i < _arrayName.count; i++) {
        if ([s1 isEqualToString:_arrayName[i]] && [s2 isEqualToString:_arrayClass[i]]) {
            boo1 = 1;
            boo2 = 1;
            t = i;
            break;
        }

    }
    

    if (s1.length > 0 && s2.length > 0 ){
        _textField1.text = @"";
        _textField2.text = @"";
        if (boo1 != 1 && boo2 != 1) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"此只因不存在" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确认删除" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction1 = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [self->_arrayName removeObjectAtIndex:t];
                [self->_arrayClass removeObjectAtIndex:t];
                [self->_arrayScore removeObjectAtIndex:t];
                [self.delegate deleteName:self->_arrayName deleteClass:self->_arrayClass deleteScore:self->_arrayScore];
                [self dismissViewControllerAnimated:YES completion:nil];
            }];
            UIAlertAction *confirmAction2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            }];
            [self.alert addAction:confirmAction2];
            [self.alert addAction:confirmAction1];
            [self presentViewController:self.alert animated:YES completion:nil];
        }
    } else {
        self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入不能为空" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [self.alert addAction:confirmAction];
        [self presentViewController:self.alert animated:YES completion:nil];
    }
}

五、更改功能

【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c
笔者的更改功能是用来更改积分的,需要输入需要更改的名字与鸡圈,以此来避免重名导致更改错误的情况,然后输入我们需要更改的程序,然后将数据回传给我们的功能界面

- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)confirm {
    NSString *s1 = _textField1.text;
    NSString *s2 = _textField2.text;
    NSString *s3 = _textField3.text;
    
    int f1 = 0;
    int f2 = 0;
    int f3 = 0;
    
    int boo1 = 0;
    int boo2 = 0;
    int boo3 = 0;
    
    for (int i = 0; i < _arrayName.count; i++) {
        if ([s1 isEqualToString:_arrayName[i]] && [s2 isEqualToString:_arrayClass[i]]) {
            boo1 = 1;
            boo2 = 1;
            f1 = i;
            f2 = i;
            break;
        }
        if ((s3.integerValue < 0 || s3.integerValue > 100 || s2.integerValue < 0 || s2.integerValue > 10) ) {
            boo3 = 1;
            break;
        }
    }
    

    if (s1.length > 0 && s2.length > 0 && s3.length > 0){
        _textField1.text = @"";
        _textField2.text = @"";
        _textField3.text = @"";
        if (boo1 == 0 && boo2 == 0) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"此只因不存在" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else if (boo3 == 1) {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入信息不合法" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            }];
            [self.alert addAction:confirmAction];
            [self presentViewController:self.alert animated:YES completion:nil];
        } else {
            self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"确认更改" preferredStyle:UIAlertControllerStyleAlert];
            UIAlertAction *confirmAction1 = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
                [self->_arrayName replaceObjectAtIndex:f1 withObject:s1];
                [self->_arrayClass replaceObjectAtIndex:f1 withObject:s2];
                [self->_arrayScore replaceObjectAtIndex:f1 withObject:s3];
                [self.delegate changeName:self->_arrayName changeClass:self->_arrayClass changeScore:self->_arrayScore];
                [self dismissViewControllerAnimated:YES completion:nil];
            }];
            UIAlertAction *confirmAction2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

            }];
            [self.alert addAction:confirmAction2];
            [self.alert addAction:confirmAction1];
            [self presentViewController:self.alert animated:YES completion:nil];
        }
    } else {
        self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"输入不能为空" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [self.alert addAction:confirmAction];
        [self presentViewController:self.alert animated:YES completion:nil];
    }
}

六、查找功能

【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c
因为存在不同鸡圈中有相同人名的情况,所以笔者这里仅仅根据名字来查找我们所需要的信息

- (void)back {
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)confirm {
    _arrayFindName = [[NSMutableArray alloc] init];
    _arrayFindClass = [[NSMutableArray alloc] init];
    _arrayFindScore = [[NSMutableArray alloc] init];

    
    NSString *s1 = _textField1.text;

    int count = 0;
    
    for (int i = 0; i < _arrayName.count; i++) {
        if ([s1 isEqualToString:_arrayName[i]]) {
            [_arrayFindName addObject:_arrayName[i]];
            [_arrayFindClass addObject:_arrayClass[i]];
            [_arrayFindScore addObject:_arrayScore[i]];
            count++;
        }
    }
    if (count == 0) {
        self.alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"此只因不存在" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }];
        [self.alert addAction:confirmAction];
        [self presentViewController:self.alert animated:YES completion:nil];
    } else {
        count = 0;
        [_tableView reloadData];
    }
    
}

七、排序功能

【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c
排序功能就比较简单了,这里既可以用我们c语言的排序方法来实现,也可以用OC创建排序描述符来实现

- (void)sort {
//    // 创建排序描述符,按照成绩降序排序
//    NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:nil ascending:NO comparator:^NSComparisonResult(id obj1, id obj2) {
//        // 这里假设成绩为字符串类型,如果成绩是数字类型,可以将其转换为 NSNumber 进行比较
//        return [obj1 compare:obj2 options:NSNumericSearch];
//    }];
//
//    // 对 _arrayScore 进行排序
//    NSArray *sortedArray = [_arrayScore sortedArrayUsingDescriptors:@[sortDescriptor]];
//
//    // 使用排序描述符对 _arrayName 和 _arrayClass 进行重排,保持对应关系
//    _arrayName = [[NSMutableArray alloc] initWithArray:[_arrayName sortedArrayUsingDescriptors:@[sortDescriptor]]];
//    _arrayClass = [[NSMutableArray alloc] initWithArray:[_arrayClass sortedArrayUsingDescriptors:@[sortDescriptor]]];
//    _arrayScore = [[NSMutableArray alloc] initWithArray:sortedArray];
//
//    // 刷新表格
//    [_tableView reloadData];
    
    for (int i = 0; i < _arrayName.count - 1; i++) {
        for (int j = i + 1; j < _arrayName.count; j++) {
            if ([_arrayScore[i] intValue] < [_arrayScore[j] intValue]) {//需要注意字符串比较,要转换为int类型比较
                id temp = _arrayName[i];
                _arrayName[i] = _arrayName[j];
                _arrayName[j] = temp;
                
                temp = _arrayClass[i];
                _arrayClass[i] = _arrayClass[j];
                _arrayClass[j] = temp;
                
                temp = _arrayScore[i];
                _arrayScore[i] = _arrayScore[j];
                _arrayScore[j] = temp;
            }
        }
    }
    [_tableView reloadData];
}

八、退出功能

【iOS】App仿写--管理系统,ios,cocoa,macos,ui,objective-c
退出功能只有两段代码

-(void)exit {
    // 获取主线程对象
    UIApplication *app = [UIApplication sharedApplication];
    
    // 发送退出信号,立即终止应用程序
    [app performSelector:@selector(terminateWithSuccess) withObject:nil afterDelay:0.0];
}

总结

这里只是管理系统的一种模版,大家可以通过实际需求来更改代码来统计数据文章来源地址https://www.toymoban.com/news/detail-605060.html

到了这里,关于【iOS】App仿写--管理系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 便捷好用的iOS文件管理App

    本文介绍了一款功能强大、免费的iOS文件管理App——克魔助手。通过使用克魔助手,用户可以轻松管理手机存储空间,清理垃圾文件,整理文件,并进行文件传输和截图操作。本文将详细介绍克魔助手的各项功能,并提供相关操作指南。 随着手机使用频率的增加,存储空间的

    2024年01月16日
    浏览(24)
  • SwiftUI 实现一个 iOS 上 Files App 兼容的文件资源管理器

    在 SwiftUI 中自己白手起家写一个 iOS(或iPadOS)上迷你的文件资源管理器是有些难度滴,不过从 iOS 11 (2017年) 官方引入自家的 Files App 之后,我们就可以借助它的魔力轻松完成这一个功能了。 如上所示,我们使用 SwiftUI 原生功能完成了一个小巧的 iOS Files App 文件管理器,

    2024年02月10日
    浏览(38)
  • IOS设置系统代理+APP不走代理绕过方式

    确保手机和pc端网络连接同一个网络 1、设置burp端 2、手机进行代理设置   3、手机端访问代理,点击右上角下载burp证书,点击允许    点击已下载描述文件,选择安装  安装成功  4、通用--关于本机--证书信任设置,勾选我们已经安装的证书  5、然后就能抓到数据包啦 关闭

    2024年02月09日
    浏览(35)
  • App备案与iOS云管理式证书 ,公钥及证书SHA-1指纹的获取方法

    引言 在iOS应用程序开发过程中,进行App备案并获取公钥及证书SHA-1指纹是至关重要的步骤。本文将介绍如何通过appuploader工具获取iOS云管理式证书 Distribution Managed 公钥及证书SHA-1指纹,帮助开发者更好地理解和应用该过程。 正文 iOS应用程序的备案和证书SHA-1指纹获取是确保应

    2024年01月15日
    浏览(39)
  • 苹果ios的系统app应用WebClip免签应用开源及方式原理

    在移动设备上,为了方便访问我们经常使用的网站或服务,我们经常会希望将其添加到主屏幕上,以便快速启动。虽然我们可以通过使用浏览器书签实现这一目标,但添加一个图标到主屏幕上,使得它看起来与原生App无异,将为用户提供更好的使用体验。在本文中,我们将介

    2024年02月04日
    浏览(37)
  • 苹果手机的ios系统ipa应用app文件怎么安装手机上

    当您有一个.ipa安装包时,您可以使用以下方法将其安装到手机上: 方法1:使用Xcode 连接设备:使用USB将您的iPhone或iPad设备连接到您的电脑。 打开Xcode:打开Xcode开发工具。 选择设备:在Xcode的顶部工具栏中,选择您连接的设备作为目标设备。 导入.ipa文件:在Xcode左侧导航栏

    2024年02月04日
    浏览(57)
  • 解决苹果手机ios系统app store无法下载讯飞有声的问题

    最近新买了一台苹果手机,更新系统以后发现“讯飞有声”无法下载,愁坏我了,我是讯飞有声的超级老客户了,很多年前就开始用了,几乎每天都使用,听一些公众号的文章。 具体什么原因导致app下架的不清楚,但是翻了一下知乎,发现可以通过爱思助手来操作。尝试了一

    2024年02月11日
    浏览(50)
  • App备案-iOS云管理式证书 Distribution Managed 公钥及证书SHA-1指纹的获取方法

    根据近日工业和信息化部发布的《工业和信息化部关于开展移动互联网应用程序备案工作的通知》,相信不少要进行IOS平台App备案的朋友遇到了一个问题,就是apple不提供云管理式证书的下载,也就无法获取公钥及证书SHA-1指纹。  已经上架的应用不想重新打包发布的话。可以

    2024年02月08日
    浏览(37)
  • Mac菜单栏图标管理工具:Bartender 5 完美兼容MacOS Sonoma 14系统

    Bartender 5 是一款流行的软件程序,专为酒店行业的调酒师和专业人士设计。它提供了一系列功能和工具来简化酒吧或餐厅的饮料订单、库存和客户偏好的管理流程。Bartender 5 的一些主要功能包括: 1. 饮料配方:该软件包括一个全面的饮料配方数据库,使调酒师可以轻松搜索和

    2024年02月08日
    浏览(33)
  • Electron-React18-MacOS桌面管理系统|electron27+react仿mac桌面

    基于 React18+Electron27+ArcoDesign 仿macOS桌面端系统框架 ElectronMacOS 。 electron-react-macOs 基于 electron27.x+vite4+react18+arcoDesign+zustand 等技术构建桌面版仿MacOs框架系统解决方案。支持 中英文/繁体、dark+light主题、桌面多层级路由、多窗口路由页面、动态换肤、Dock悬浮菜单 等功能。 Elec

    2024年02月05日
    浏览(26)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包