iOS原生refresh(UIRefreshControl)
转载:http://www.2cto.com/kf/201504/392431.html
//
// ViewController.m
// 代码自定义cell
//
// Created by mac on 15/4/18.
// Copyright (c) 2015年 mac. All rights reserved.
//
#import "ViewController.h"
//#import "myTableViewCell.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self addArrayM];
_myTableView = [[UITableView alloc]initWithFrame:[UIScreen mainScreen].bounds style:UITableViewStylePlain];
_myTableView.delegate = self;
_myTableView.dataSource = self;
_myTableView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:_myTableView];
[_myTableView reloadData];
/******内置刷新的常用属性设置******/
_refresh = [[UIRefreshControl alloc] init];
_refresh.tintColor = [UIColor redColor];
_refresh.attributedTitle =[[NSAttributedString alloc]initWithString:@"智课网正在加载"];
[_refresh addTarget:self action:@selector(pullToRefresh) forControlEvents:UIControlEventValueChanged];
[_myTableView addSubview:_refresh];
// UIActivityViewController *act = [[UIActivityViewController alloc]initw];
// Do any additional setup after loading the view, typically from a nib.
}
-(void)pullToRefresh
{
[self.arrayM addObjectsFromArray:self.arrayM];
[_myTableView reloadData];
[NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(timerStop) userInfo:nil repeats:NO];
}
-(void)timerStop
{
[_refresh endRefreshing];
}
-(void)addArrayM
{
NSString *one = @"A";
NSString *one1 = @"B";
NSString *one11 = @"C";
NSString *one111 = @"D";
NSString *one1111= @"E";
NSString *one11111= @"F";
NSString *one111111 = @"G";
_arrayM = [NSMutableArray arrayWithObjects:one,one1,one11,one111,one1111,one11111,one111111, nil];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [_arrayM count];
}
-(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.imageView.image = [UIImage imageNamed:@"iosshare"];
cell.textLabel.text = [_arrayM objectAtIndex:indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"点击我了");
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 80;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
iOS原生refresh(UIRefreshControl)的更多相关文章
- JS调用Android、Ios原生控件
在上一篇博客中已经和大家聊了,关于JS与Android.Ios原生控件之间相互通信的详细代码实现,今天我们一起聊一下JS调用Android.Ios通信的相同点和不同点,以便帮助我们在进行混合式开发时, ...
- [调整] Firemonkey iOS 原生 Edit 透明框, 改变框色
说明:iOS 原生 Edit 透明框 适用:Berlin Firemonkey 方法:在 StyleLookup 输入 transparentedit 效果: 如果有图片 Image 在这二个 Edi ...
- unity导出工程导入到iOS原生工程中详细步骤
一直想抽空整理一下unity原生工程导入iOS原生工程中的详细步骤.做iOS+vuforia+unity开发这么长时间了.从最初的小小白到现在的小白.中间趟过了好多的坑.也有一些的小小收货.做一个喜欢 ...
- iOS原生地图开发指南续——大头针与自定义标注
iOS原生地图开发指南续——大头针与自定义标注 出自:http://www.sxt.cn/info-6042-u-7372.html 在上一篇博客中http://my.oschina.net/u/23 ...
- iOS原生项目中集成React Native
1.本文的前提条件是,电脑上已经安装了CocoaPods,React Native相关环境. 2.使用Xcode新建一个工程.EmbedRNMeituan [图1] 3.使用CocoaPods安装Re ...
- Cordova - 与iOS原生代码交互2(使用Swift开发Cordova的自定义插件)
在前一篇文章中我介绍了如何通过 js 与原生代码进行交互(Cordova - 与iOS原生代码交互1(通过JS调用Swift方法)),当时是直接对Cordova生成的iOS工程项目进行编辑操作的(添加 ...
- cocos2d-x + Lua接入iOS原生SDK的实现方案[转]
相信很多朋友在使用cocos2d-x+lua开发游戏时都遇到过接入iOS原生SDK的问题,比如常见的接应用内支付SDK,广告SDK或是一些社交平台SDK等等,我也没少接过这类SDK.这篇文章主要是对我 ...
- iOS原生地图开发详解
在上一篇博客中:http://my.oschina.net/u/2340880/blog/414760.对iOS中的定位服务进行了详细的介绍与参数说明,在开发中,地位服务往往与地图框架结合使用,这篇博 ...
- iOS原生地图开发进阶——使用导航和附近兴趣点检索
iOS原生地图开发进阶——使用导航和附近兴趣点检索 iOS中的mapKit框架对国际化的支持非常出色.在前些篇博客中,对这个地图框架的基础用法和标注与覆盖物的添加进行了详细的介绍,这篇博客将介绍两个更 ...
随机推荐
- Linux相关
可以用secureCRT远程连接Linux系统,进入tomcat,并且启动tomcat:bin/startup.sh 查看实时日志状态:tail -f logs/catalina.out
- C#用Zlib压缩或解压缩字节数组
/// <summary> /// 复制流 /// </summary> /// <param name="input">原始流</par ...
- 杭电OJ分类
基础题:1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.1032.1037.1040.1048.1056.1058.1 ...
- WinDbg抓取程序报错dump文件的方法
程序崩溃的两种主要现象: a. 程序在运行中的时候,突然弹出错误窗口,然后点错误窗口的确定时,程序直接关闭 例如: “应用程序错误” “C++错误之类的窗口” “程序无响应” “假死”等 此种崩溃特点 ...
- where条件的lambda转化为sql语句
网上找的源码,但是博主说有bug 让自己调试.这个是我经过多次修改后的代码,可以直接用 public static class LambdaToSqlHelper { #region 基础方法 #re ...
- pdo 抽象层连接数据库
<?php header("content-type:text/html; charset=utf8"); try{ $pdo=new PDO(' ...
- LeetCode OJ 217.Contains Duplicate
Given an array of integers, find if the array contains any duplicates. Your function should return t ...
- 贝叶斯分类器(Bayes分类器)
贝叶斯(Bayes)定理 (条件概率) 贝叶斯分类器(Bayes分类器) 1概念: 将每个属性及类别标记视为随机变量 给定一个具有属性集合(A1, A2,…,An)的记录 目标是预测 ...
- 7.在第4题中Hello.class所在路径下, 输入命令:java Hello.class,会出现什么结果,为什么?
java Hello已经是加载类了
- Xcode6无法用xib得问题解决方法
1.创建一个新工程,选择singleView application 2.将storyboard和launchscreen删除,选择moveToTrash 3.删除info.plist文件中Main ...