#import "AViewController.h"

@interface AViewController () <UIActionSheetDelegate>

@end

@implementation AViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

}

return self;

}

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view.

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"下一页" style:UIBarButtonItemStyleDone target:self action:@selector(nextClick)];

}

- (void)nextClick

{

int num = self.navigationController.viewControllers.count+1;

int r = arc4random_uniform(256);

int g = arc4random_uniform(256);

int b = arc4random_uniform(256);

AViewController *av = [[AViewController alloc]init];

av.navigationItem.title = [NSString stringWithFormat:@"第%d页",num];

av.view.backgroundColor = [UIColor colorWithRed:r/255.0f green:g/255.0f blue:b/255.0f alpha:1];

av.hidesBottomBarWhenPushed = YES;

av.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:av action:@selector(backClick)];

[self.navigationController pushViewController:av animated:YES];

}

- (void)backClick

{

UIActionSheet *as = [[UIActionSheet alloc]initWithTitle:@"返回到" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"首页" otherButtonTitles:@"上一页",@"第三页",@"第五页", nil];

[as showInView:self.tabBarController.view];

}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex

{

NSArray *arr = self.navigationController.viewControllers;

switch (buttonIndex) {

case 0:

{

[self.navigationController popToRootViewControllerAnimated:YES];

}

break;

case 1:

{

[self.navigationController popViewControllerAnimated:YES];

}

break;

case 2:

{

if (arr.count > 2) {

[self.navigationController popToViewController:[arr objectAtIndex:2] animated:YES];

}

}

break;

case 3:

{

if (arr.count > 4) {

[self.navigationController popToViewController:[arr objectAtIndex:4] animated:YES];

}

}

break;

default:

break;

}

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

#import "BViewController.h"

#import "CViewController.h"

@interface BViewController ()

@end

@implementation BViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

return self;

}

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view from its nib.

}

//保存按钮点击事件

- (IBAction)saveClick:(UIButton *)sender

{

[self.view endEditing:YES];

UITextField *name = (UITextField *)[self.view viewWithTag:1];

UITextField *age = (UITextField *)[self.view viewWithTag:2];

UITextField *num = (UITextField *)[self.view viewWithTag:3];

NSString *str = [NSString stringWithFormat:@"姓名:%@\n年龄:%@\n成绩:%@",name.text,age.text,num.text];

CViewController *cv = [self.tabBarController.viewControllers objectAtIndex:2];

[cv.dataArr addObject:str];

}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

[self.view endEditing:YES];

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

#import <UIKit/UIKit.h>

@interface CViewController : UIViewController

@property (nonatomic,retain)NSMutableArray *dataArr;

@end

#import "CViewController.h"

#import "AppDelegate.h"

@interface CViewController () <UITableViewDataSource,UITableViewDelegate>

{

UITableView *_myTableView;

}

@end

@implementation CViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

_dataArr = [[NSMutableArray alloc]init];

}

return self;

}

- (void)viewWillAppear:(BOOL)animated

{

[_myTableView reloadData];

}

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view.

_myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 40, 320, [UIScreen mainScreen].bounds.size.height-49-40)];

_myTableView.delegate = self;

_myTableView.dataSource = self;

[self.view addSubview:_myTableView];

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

return _dataArr.count;

}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

return 80;

}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"qqq"];

if (!cell) {

cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"qqq"];

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 320, 80)];

label.numberOfLines = 0;

label.backgroundColor = [UIColor yellowColor];

label.tag = 1;

[cell.contentView addSubview:label];

}

UILabel *la = (UILabel *)[cell.contentView viewWithTag:1];

la.text = [_dataArr objectAtIndex:indexPath.row];

return cell;

}

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

{

[_dataArr removeObjectAtIndex:indexPath.row];

[_myTableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

#import "DViewController.h"

@interface DViewController () <UIScrollViewDelegate>

{

UIScrollView *_sview1;

UIScrollView *_sview2;

UIScrollView *_sview3;

}

@end

@implementation DViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

return self;

}

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view.

_sview1 = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 40, 320, 120)];

_sview1.pagingEnabled = YES;

_sview1.delegate = self;

_sview1.backgroundColor = [UIColor redColor];

_sview1.contentSize = CGSizeMake(320*10, 120);

for (int i = 0; i<10; i++) {

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(i*320, 0, 320, 120)];

label.text = [NSString stringWithFormat:@"%i只青蛙",i+1];

label.textAlignment = NSTextAlignmentCenter;

[_sview1 addSubview:label];

}

[self.view addSubview:_sview1];

_sview2 = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 170, 320, 120)];

_sview2.backgroundColor = [UIColor yellowColor];

_sview2.delegate = self;

_sview2.pagingEnabled = YES;

_sview2.contentSize = CGSizeMake(320*20, 120);

for (int i = 0; i<20; i++) {

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(i*320, 0, 320, 120)];

label.text = [NSString stringWithFormat:@"%i只公鸡",i+1];

label.textAlignment = NSTextAlignmentCenter;

[_sview2 addSubview:label];

}

[self.view addSubview:_sview2];

_sview3 = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 300, 320, 120)];

_sview3.backgroundColor = [UIColor brownColor];

_sview3.pagingEnabled = YES;

_sview3.delegate = self;

_sview3.scrollEnabled = NO;

_sview3.contentSize = CGSizeMake(320*40, 120);

for (int i=0; i<41;i++) {

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(i*320, 0, 320, 120)];

label.text = [NSString stringWithFormat:@"%i条腿",i];

label.textAlignment = NSTextAlignmentCenter;

[_sview3 addSubview:label];

}

[self.view addSubview:_sview3];

}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView

{

int a = scrollView.contentOffset.x/320 + 1;

if (scrollView==_sview1) {

[_sview3 setContentOffset:CGPointMake(a*320*4, 0)animated:YES];

} else {

[_sview3 setContentOffset:CGPointMake(a*320*2, 0) animated:YES];

}

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

#import "EViewController.h"

@interface EViewController ()

@end

@implementation EViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

return self;

}

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view from its nib.

}

//slider滑动事件

- (IBAction)colorChange:(UISlider *)sender

{

UISlider *s1 = (UISlider *)[self.view viewWithTag:11];

UISlider *s2 = (UISlider *)[self.view viewWithTag:12];

UISlider *s3 = (UISlider *)[self.view viewWithTag:13];

self.view.backgroundColor = [UIColor colorWithRed:s1.value green:s2.value blue:s3.value alpha:1];

}

//保存按钮点击事件

- (IBAction)saveClick:(UIButton *)sender

{

for (UIViewController *vc in self.tabBarController.viewControllers) {

vc.view.backgroundColor = self.view.backgroundColor;

}

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

@end

#import "MyTabBar.h"

#import "AViewController.h"

#import "BViewController.h"

#import "CViewController.h"

#import "DViewController.h"

#import "EViewController.h"

@interface MyTabBar ()

@end

@implementation MyTabBar

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

if (self) {

// Custom initialization

}

return self;

}

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view.

AViewController *av = [[AViewController alloc]init];

BViewController *bv = [[BViewController alloc]init];

CViewController *cv = [[CViewController alloc]init];

DViewController *dv = [[DViewController alloc]init];

EViewController *ev = [[EViewController alloc]init];

av.title = @"首页";

bv.title = @"添加";

cv.title = @"联系人";

dv.title = @"动态";

ev.title = @"设置";

UINavigationController *an = [[UINavigationController alloc]initWithRootViewController:av];

NSArray *controllers = [NSArray arrayWithObjects:an,bv,cv,dv,ev, nil];

self.viewControllers = controllers;

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

循环&信息添加&颜色修改的更多相关文章

  1. 使用ADO对象添加、修改、删除数据

    使用ADO对象对数据库中的数据进行添加.修改和删除等操作.首先创建一个ADO类,通过ADO类连接数据库,并打开记录集.例如,使用ADO对象添加.修改.删除数据,程序设计步骤如下:(1)创建一个基于对话 ...

  2. datagrid 添加、修改、删除(转载)

    原链接:JQueryEasyUI学习笔记(十)datagrid 添加.修改.删除 基于datagrid框架的删除.添加与修改: 主要是批量删除,双击表单修改.选中行修改,增加行修改,再有就是扩展edi ...

  3. Quartz动态添加,修改,删除任务(暂停,任务状态,恢复,最近触发时间)

    首页 博客 学院 下载 图文课 论坛 APP 问答 商城 VIP会员 活动 招聘 ITeye GitChat 写博客 小程序 消息 登录注册 关闭 quartz_Cron表达式一分钟教程 09-05 ...

  4. 给手绘图着色(添加颜色或色彩):CVPR2020论文点评

    给手绘图着色(添加颜色或色彩):CVPR2020论文点评 Learning to Shade Hand-drawn Sketches 论文链接:https://arxiv.org/pdf/2002.1 ...

  5. ExtJS 4.2 业务开发(三)数据添加和修改

    接上面的船舶管理业务,这里介绍添加和修改操作. 目录 1. 添加操作 2. 修改操作 3. 在线演示 1. 添加操作 1.1 创建AddShipWindow.js 在业务中的view目录下创建一个Ad ...

  6. MVC5 网站开发之八 栏目功能 添加、修改和删除

    本次实现栏目的浏览.添加.修改和删除. 栏目一共有三种类型. 常规栏目-可以添加子栏目,也可以添加内容模型.当不选择内容模型时,不能添加内容. 单页栏目-栏目只有一个页面,可以设置视图. 链接栏目-栏 ...

  7. ASP.NET MVC搭建项目后台UI框架—6、客户管理(添加、修改、查询、分页)

    目录 ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NE ...

  8. Jquery EasyUI的添加,修改,删除,查询等基本操作介绍

    http://www.jb51.net/article/42016.htm 初识Jquery EasyUI看了一些博主用其开发出来的项目,页面很炫,感觉功能挺强大,效果也挺不错,最近一直想系统学习一套 ...

  9. IIS环境下如何批量添加、修改、删除绑定的域名

    IIS环境下如何批量添加和修改所绑定域名 1.关闭IISADMIN服务和W3SVC服务,可以从服务里面关闭,也可以直接执行命令:net stop iisadmin /y: 2.打开“C:\WINDOW ...

随机推荐

  1. java-学习10

    使用return结束一个方法 public class function3 { public static void main(String[] args) { System.out.println( ...

  2. hive mysql 初始化

    原文链接:https://juejin.im/post/59c3f8f75188255be81f91d9#heading-17 Apache Hive-2.3.0 快速搭建与使用 Hive 简介 Hi ...

  3. JVM 图解--1.6,1.7,1.8

  4. react input的几个坑

    [react input的几个坑] 1.input标签中设置value后,input进入controlled模式,valuechange由自动变为手动,导致input无法编辑.如: <input ...

  5. JMeter调试工具--Debug Sampler(转载)

    转载自 http://www.cnblogs.com/fengpingfan Debug Sampler添加路径:[添加 / Sampler / Debug Sampler],面板设置如下: 打开JM ...

  6. 【Scheme】树结构

    将表作为序列的表示方式,可以推广到元素本身也是序列的序列.例如,我们可以认为对象((1 2) 3 4)是通过(cons (list 1 2) (list 3 4))构造出来的. 这个表包含三个项,其中 ...

  7. 第十章 优先级队列 (xa3)左式堆:插入与删除

  8. Codeforces Beta Round #44 (Div. 2)

    Codeforces Beta Round #44 (Div. 2) http://codeforces.com/contest/47 A #include<bits/stdc++.h> ...

  9. Wannafly挑战赛13 B:Jxc军训(逆元)

    题目描述 在文某路学车中学高一新生军训中,Jxc正站在太阳下站着军姿,对于这样的酷热的阳光,Jxc 表示非常不爽. Jxc将天空看做一个n*n的矩阵,此时天上有m朵云,这些云会随机分布在m个不同的位置 ...

  10. 项目总结08:spring quartz 定时器Demo

    将定时器用到的quartz.jar放在lip文件下 quartz.xml文件(完整) <?xml version="1.0" encoding="UTF-8&quo ...