标签 ios开发 下的文章

这一年的工作是彻底结束了! 干杯!

这一年的工作是彻底结束了! 干杯!
三个项目的上线,更新在刚刚完成了!
这一年的工作是彻底结束了! 干杯!
记录一点东西!

Because the reasons for mainland China network fluctuations, if there is a network error, can not access. please wait for a while in the test! thank you very much!

2015-12-17---UI9_UITableView协议方法

//
// RootViewController.m
// UI9_UITableView协议方法
//
// Created by YIem on 15/12/17.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

@interface RootViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    //////tableView
    
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];
    [tableView release];
    // tableView的头部脚部区域
    // 头 (只有高度起作用)
    UIView *header = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    header.backgroundColor = [UIColor redColor];
    tableView.tableHeaderView = header;
    // 脚(x值和高度起作用)
    UIView *foot = [[UIView alloc]initWithFrame:CGRectMake(0, 100, 100, 100)];
    foot.backgroundColor  = [UIColor yellowColor];
    tableView.tableFooterView = foot;
    
    // tableView结构
    // tableHeaderView + tableView + tableFooterView
    // tableView -> section + row
    // section -> header + row + footer
    

}

warning 必须实现的两个协议方法

// 行数

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    return 10;
    }
  • (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    }

// 设置cell

  • (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
    if (!cell) {

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

    }

    // 设置
    // indePath 定位信息 包含section和row
    cell.textLabel.text = [NSString stringWithFormat:@"s: %ld, r: %ld", indexPath.section, indexPath.row];
    return cell;
    }

pragma mark - 其他协议方法

  • (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
    {
    return 3;
    }

// 分区头名称

  • (NSString )tableView:(UITableView )tableView titleForHeaderInSection:(NSInteger)section
    {
    return @"头头头";
    }

// 分区脚部名称

  • (NSString )tableView:(UITableView )tableView titleForFooterInSection:(NSInteger)section
    {
    return @"脚脚脚";
    }

// 自定义头部区域

  • (UIView )tableView:(UITableView )tableView viewForHeaderInSection:(NSInteger)section
    {
    UIView *header = [[UIView alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    header.backgroundColor = [UIColor grayColor];
    return [header autorelease];
    }

// 自定义脚部区域

  • (UIView )tableView:(UITableView )tableView viewForFooterInSection:(NSInteger)section
    {
    UIView *footer = [[UIView alloc]init];
    footer.backgroundColor = [UIColor blackColor];
    return [footer autorelease];

    }

// 高度控制
// 行高

  • (CGFloat)tableView:(UITableView )tableView heightForRowAtIndexPath:(NSIndexPath )indexPath
    {
    return 100;
    }

// 头部高度

  • (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    {
    return 50;
    }

// 脚部高度

  • (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
    {
    return 150;
    }

// tableView右部索引栏

  • (NSArray )sectionIndexTitlesForTableView:(UITableView )tableView
    {
    return @[@"a", @"1", @"啦"];
    }

// tableView点击方法

  • (void)tableView:(UITableView )tableView didSelectRowAtIndexPath:(NSIndexPath )indexPath
    {

    NSLog(@"点击");
    // 取消选中效果
    [tableView deselectRowAtIndexPath:indexPath animated:YES];

    }

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

    }

*/

@end

UI9_UITableView---

//
// RootViewController.m
// UI9_UITableView
//
// Created by YIem on 15/12/17.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

@interface RootViewController ()<UITableViewDataSource,UITableViewDelegate>

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    ///************UITableView 表视图*************////
    UITableView *tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
    tableView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:tableView];
    [tableView release];
    
    
    ////// 1. 设置代理人
    tableView.delegate = self;
    tableView.dataSource = self;
    
    // 设置
    // 行高
    tableView.rowHeight = 100;
    // 分割线样式
    tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    // 分割线颜色
    tableView.separatorColor = [UIColor redColor];

    }

warning 实现tableView时 必须实现的两个协议方法

// 1.每个分区中的cell行数

  • (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
    // 前没有设置分区时 默认分区数为1
    return 10;
    }

// 2.设置每个cell内容
// 参数1: 触发方法的tableView
// 参数2: cell的位置信息

  • (UITableViewCell )tableView:(UITableView )tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

    // indexPath 用于定位每个cell
    // 包含: roe(行号) / section(分区hao)

if 0

// 创建cell
UITableViewCell *cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil] autorelease];
// 设置
// 标题
cell.textLabel.text = @"姓名";
// 副标题
cell.detailTextLabel.text = @"phoneNumber";
// 图片
cell.imageView.image = [UIImage imageNamed:@"1"];
// 辅助视图

// cell.accessoryType = UITableViewCellAccessoryDetailButton;// 感叹号
// cell.accessoryType = UITableViewCellAccessoryCheckmark;// 对号
// cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;// 感叹号,对号

cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// accessoryView 添加视图

endif


// cell的重用机制
// 1.从重用池中获取cell
// 参数: 重用机制 (识别不同重用池)
UITableViewCell  *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
// 2.判断cell是否存在
// !cell 等同 cell == nil
if (!cell) {
    // 3.创建cell
    // 参数1;cell的样式
    // 参数2: cell的重用标识(区分进入哪个重用池)
    cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"] autorelease];

warning 判断中 只写cell创建 不要写赋值

}
// 4.设置cell
cell.textLabel.text = @"标题";
cell.detailTextLabel.text = @"副标题";
cell.imageView.image = [UIImage imageNamed:@"1"];
cell.accessoryType = UITableViewCellAccessoryCheckmark;



// 辅助视图
// 图片

// UIImageView *img = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];
// img.image = [[UIImage imageNamed:@"1"] autorelease];
// cell.accessoryView = img;


// 开关 switch
cell.accessoryView = [[UISwitch alloc]initWithFrame:CGRectMake(0, 0, 30, 30)];


// 将设置好的cell对象返回
return cell;

}

  • (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.

    }

/*

pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation

  • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.

    }

*/

@end

UI8_轮播图-图片无限滚动iOS

屏幕快照 2015-12-16 下午7.14.14.png
// RootViewController.m
// **UI8_轮播图
//**
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

@interface RootViewController ()<UIScrollViewDelegate>

@property (nonatomic, retain) UIScrollView *scrollView;
@property (nonatomic, retain) UIPageControl *page;
@property (nonatomic, retain) NSTimer *timer;

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.title = @"轮播图";
    








- 阅读剩余部分 -

2015-15-16--UI8_练习--传值练习

//
// AppDelegate.h
// UI8_练习
//
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end







- 阅读剩余部分 -

2015-12-16-UI8_Block-----block 快语法(闭包)

//
// AppDelegate.h
// UI8_Block
//
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end


//
// AppDelegate.m
// UI8_Block
//
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "AppDelegate.h"

import "RootViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

-(void)dealloc
{

[_window release];

[super dealloc];
}

  • (BOOL)application:(UIApplication )application didFinishLaunchingWithOptions:(NSDictionary )launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];

    RootViewController *rotVC = [[RootViewController alloc]init];
    UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:rotVC];
    self.window.rootViewController = navi;

    [rotVC release];
    [navi release];

    / Block 快语法*/

    [_window release];
    return YES;
    }

  • (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }
  • (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }
  • (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }
  • (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }
  • (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

@end




































- 阅读剩余部分 -

2015-15-16- UI8_协议传值

//
// AppDelegate.h
// UI8_协议传值
//
// Created by YIem on 15/12/16.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end







- 阅读剩余部分 -

2015-12-16 UI7作业1--创建三个控制器

//
**创建三个控制器 要求 :
1.命名 First ~ Third。 2.分别设置背景颜⾊色红、灰、蓝。 3.如⽰示例完成⾃自定义导航栏。**

//
// AppDelegate.h
// UI7_作业
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end









- 阅读剩余部分 -

2015-12-16--UI7_页面跳转 - 传值

//
// AppDelegate.h
// UI7_页面跳转
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (retain, nonatomic) UIWindow *window;

@end







- 阅读剩余部分 -

2015-12-16 UI7_UINavigationController

//
// RootViewController.m
// UI7_UINavigationController
//
// Created by YIem on 15/12/15.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor redColor];
    
    //********< 导航栏设置>************//
    //< 半透明效果 >****
    self.navigationController.navigationBar.translucent = YES;
    // 半透明下 坐标原点在屏幕左上角   默认半透明
    // 不透明下 坐标原点在导航栏左下角
    
    UIView *aview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
    aview.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:aview];
    [aview release];
    //**< 显示/隐藏> ****
    self.navigationController.navigationBarHidden = NO;
    //**< 导航栏背景颜色>****
    self.navigationController.navigationBar.backgroundColor = [UIColor grayColor];
    //**< 导航栏颜色>****
    // 状态栏(statuBar)会跟随导航栏一起变色

    // self.navigationController.navigationBar.barTintColor = [UIColor cyanColor];

    //**< 导航栏样式 >****两种方式

    // self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

    self.navigationController.navigationBar.barStyle = UIBarStyleDefault;
    
    //*****<导航标题>***

    // self.title = @"标题";

// self.navigationItem.title = @"标题";







- 阅读剩余部分 -

2015-12-15 iOS UI 实现 通讯录滚动

//
// RootViewController.miOS Simulator Screen Shot 2015年12月15日 下午12.46.17.png
// UI6_作业1
//
// Created by YIem on 15/12/14.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

import "LTView.h"

import "CellViewTableViewCell.h"

@interface RootViewController ()<UIScrollViewDelegate>

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    // Phone
    // 滚
    UIScrollView *phone = [[UIScrollView alloc]initWithFrame:self.view.frame];
    phone.backgroundColor = [UIColor grayColor];
    [self.view addSubview:phone];
    
    phone.contentSize = CGSizeMake(0, self.view.frame.size.height * 1.5);
    
    
    [phone release];
    
    //
    LTView *s1 = [[LTView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 110)];
    s1.backgroundColor = [UIColor whiteColor];
    s1.label1.text = @"卞一";
    s1.label2.text = @"1879414****";
    s1.label3.text = @"";
    s1.img.image = [UIImage imageNamed:@"900738"];
    // 添加到phone视图/// 在phone视图滚动
    [phone addSubview:s1];
    






- 阅读剩余部分 -

2015-12-15-iOS UI 实现通讯记录

iOS Simulator Screen Shot 2015年12月15日 下午12.45.50.png

//
// RootViewController.m
// Phone2
//
// Created by YIem on 15/12/12.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

import "TLView.h"

@interface RootViewController ()

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    //
    UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"AII", @"Missed"]];
    seg.frame = CGRectMake(100, 25, 150, 40);
    seg.center = CGPointMake(self.view.center.x, 50);
    [self.view addSubview:seg];
    seg.backgroundColor = [UIColor whiteColor];
    seg.selectedSegmentIndex = 0;
    [seg release];
    //
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    button.frame = CGRectMake(0, 590,self.view.frame.size.width, 70);
    [self.view addSubview:button];
    [button setBackgroundImage:[UIImage imageNamed:@"12.jpg"] forState:UIControlStateNormal];
    button.self.layer.cornerRadius = 35;
    
    






- 阅读剩余部分 -

2015-12-15-iOS UI 实现QQ聊天界面

//
iOS Simulator Screen Shot 2015年12月15日 下午12.44.43.png
// RootViewController.m
// Phone
//
// Created by YIem on 15/12/12.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

import "LTView.h"

import "PhoneViewController.h"

@interface RootViewController ()

@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.view.backgroundColor = [UIColor whiteColor];
    // 背景框
    UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"消息", @"电话"]];
    seg.frame = CGRectMake(100, 25, 150, 40);

    // seg.self.layer.cornerRadius = 30;

    seg.center = CGPointMake(self.view.center.x, 50);
    seg.selectedSegmentIndex = 0;
    seg.backgroundColor = [UIColor whiteColor];
    [seg addTarget:self action:@selector(segAction:) forControlEvents:UIControlEventValueChanged];
    [self.view addSubview:seg];
    [seg release];
    
    // 调用 搜索
    [self sousuo];
    // 调用左上角头像
    [self toxi];
    // 调用右上角
    [self youtu];

    //








- 阅读剩余部分 -

2015-12-15- iOS UI 实现TOM猫

iOS Simulator Screen Shot 2015年12月15日 下午12.43.27.png
//
// RootViewController.m
// Tom
//
// Created by YIem on 15/12/11.
// Copyright (c) 2015年 www.yiem.net YIem博客. All rights reserved.
//

import "RootViewController.h"

@interface RootViewController ()
@property (nonatomic, retain)UIImageView *imgTom1;
@end

@implementation RootViewController

  • (void)viewDidLoad {

    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    self.imgTom1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width , self.view.frame.size.height)];
    self.imgTom1.backgroundColor = [UIColor clearColor];
    [self.view addSubview:self.imgTom1];
    [_imgTom1 release];
    NSString *grassPath =  [[NSBundle mainBundle] pathForResource:@"angry_0" ofType:@"jpg"];
    self.imgTom1.image = [UIImage imageWithContentsOfFile:grassPath];
    
    // Tom1
    
    

//[self TOM1];
// [self TOMtu1];


// 按钮
[self an1];
[self an2];
[self an3];
[self an1_1];
[self an2_1];
[self an3_1];
// 隐藏按钮
[self anto];
[self anzhon];
[self anxiao];
[self anfootLeft];
[self anfootRight];

}
// 图标按钮123456

  • (void)an1
    {

    UIButton *buttomTom1 =[UIButton buttonWithType:UIButtonTypeSystem];
    buttomTom1.frame = CGRectMake(20, 400, 50, 50);
    
    [buttomTom1 setBackgroundImage:[UIImage imageNamed:@"eat.png"] forState:UIControlStateNormal];
    [buttomTom1 addTarget:self action:@selector(TOMtu1) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:buttomTom1];
    [buttomTom1 release];
    
    

}













- 阅读剩余部分 -