标签 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 ()

@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

@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

@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

@property (retain, nonatomic) UIWindow *window;

@end

- 阅读剩余部分 -

Title - Artist
0:00