抽屉效果全新

先新创建一个UIViewcontroller
再在appdelegate.m中加导航

#import “ViewController.h"

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//创建主视图
ViewController *vc = [[ViewController alloc] init];
//包装导航控制器
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
//更改主视图
self.window.rootViewController = nav;
return YES;
}

开始在viewcontroller.m中
导入头文件#import “TwoViewController.h”
@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>
{
//定义属性
UITableView *tab;
UIView *leftView;
UIView *mainView;
NSArray *arr;
BOOL isSelect;
}

-(void)viewDidLoad {
[super viewDidLoad];

//设置导航条标题
self.title = @"Main";
//设置左侧按钮
UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStyleDone target:self action:@selector(click)];
self.navigationItem.leftBarButtonItem = leftItem;
//初始化数组
arr = @[@"?个性用户表情",@"?QQ钱包",@"个性装扮",@"我的收藏"];

//创建左侧视图
leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, [UIScreen mainScreen].bounds.size.height)];
//添加到视图
[self.view addSubview:leftView];
//创建主视图
mainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,self.view.frame.size.width,self.view.frame.size.height)];
mainView.backgroundColor = [UIColor whiteColor];

//添加到视图
[self.view addSubview:mainView];
//创建图片框
UIImageView *imgV = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 300, 300)];
//设置图片
imgV.image = [UIImage imageNamed:@"2.png"];
//将图片框添加到左侧视图
[leftView addSubview:imgV];

//创建表格
tab = [[UITableView alloc] initWithFrame:CGRectMake(0, 300, 300, self.view.frame.size.height) style:UITableViewStylePlain];

//取消垂直滚动条
tab.showsVerticalScrollIndicator = NO;
//设置代理
tab.delegate = self;
//设置数据源
tab.dataSource = self;

//将表格添加到左侧view
[leftView addSubview:tab];

}

//数据源方法
//设置行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

return arr.count;

}
//设置cell内容
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

//创建可重用标识符
static NSString *ID = @"cell";
//通过可重用标识符查找
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
//判断
if (!cell) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
    
}
//设置内容
cell.textLabel.text = arr[indexPath.row];
//返回cell
return cell;

}
//点击左侧按钮方法
-(void)click{

if (isSelect == NO) {
    //        (NSTimeInterval) 时间间隔
    [UIView animateWithDuration:0.5 animations:^{
        
        //移动视图
        self.navigationController.navigationBar.transform = CGAffineTransformMakeTranslation(300, 0);
        //移动MainView
        mainView.transform = CGAffineTransformMakeTranslation(300, 0);
        
    }];
    isSelect = YES;
    
}else{
    
    //恢复原位
    [UIView animateWithDuration:0.5 animations:^{
        
        //恢复原位 导航条
        self.navigationController.navigationBar.transform = CGAffineTransformIdentity;
        
        //恢复leftView
        leftView.transform = CGAffineTransformIdentity;
        //恢复mainView
        mainView.transform = CGAffineTransformIdentity;
        
    }];
    isSelect = NO;
    
}

}
//点击屏幕的方法
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

[UIView animateWithDuration:0.5 animations:^{
    
    //恢复原位 导航条
    self.navigationController.navigationBar.transform = CGAffineTransformIdentity;
    
    //恢复leftView
    leftView.transform = CGAffineTransformIdentity;
    //恢复mainView
    mainView.transform = CGAffineTransformIdentity;
    
}];
isSelect = NO;

}
//点击单元格的方法
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

[UIView animateWithDuration:0.5 animations:^{
    //恢复原位 导航条
    self.navigationController.navigationBar.transform = CGAffineTransformIdentity;
    
    //恢复leftView
    leftView.transform = CGAffineTransformIdentity;
    //恢复mainView
    mainView.transform = CGAffineTransformIdentity;
    
} completion:^(BOOL finished) {
    
    //创建第二个控制器
    TwoViewController *twoVc = [[TwoViewController alloc] init];
    [self.navigationController pushViewController:twoVc animated:YES];
    
}];

isSelect = NO;

}

内容概要:本文系统介绍了算术优化算法(AOA)的基本原理、核心思想及Python实现方法,并通过图像分割的实际案例展示了其应用价值。AOA是一种基于种群的元启发式算法,其核心思想来源于四则运算,利用乘除运算进行全局勘探,加减运算进行局部开发,通过数学优化器加速函数(MOA)和数学优化概率(MOP)动态控制搜索过程,在全局探索与局部开发之间实现平衡。文章详细解析了算法的初始化、勘探与开发阶段的更新策略,并提供了完整的Python代码实现,结合Rastrigin函数进行测试验证。进一步地,以Flask框架搭建前后端分离系统,将AOA应用于图像分割任务,展示了其在实际工程中的可行性与高效性。最后,通过收敛速度、寻优精度等指标评估算法性能,并提出自适应参数调整、模型优化和并行计算等改进策略。; 适合人群:具备一定Python编程基础和优化算法基础知识的高校学生、科研人员及工程技术人员,尤其适合从事人工智能、图像处理、智能优化等领域的从业者;; 使用场景及目标:①理解元启发式算法的设计思想与实现机制;②掌握AOA在函数优化、图像分割等实际问题中的建模与求解方法;③学习如何将优化算法集成到Web系统中实现工程化应用;④为算法性能评估与改进提供实践参考; 阅读建议:建议读者结合代码逐行调试,深入理解算法流程中MOA与MOP的作用机制,尝试在不同测试函数上运行算法以观察性能差异,并可进一步扩展图像分割模块,引入更复杂的预处理或后处理技术以提升分割效果
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值