UI 15 UITableViewController & 系统自带快捷菜单 & 系统下拉刷新
来源:互联网 发布:javac编译多个java文件 编辑:程序博客网 时间:2024/05/22 01:46
UITableViewController 已经签订好tableView的两个协议,可以直接使用.
只要将必须完成的两个协议的内容写好即可.
下面的代码加入了系统默认的下拉刷新功能, 每次向下拉刷新时都添加一个@”哈哈”
代码实现如下:
#import "MainTableViewController.h"@interface MainTableViewController ()@property (nonatomic, retain)NSMutableArray *arr;@property(nonatomic, retain)UIRefreshControl *RefreshControl;@end@implementation MainTableViewController- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.arr = [NSMutableArray arrayWithObjects:@"宋江", @"卢俊义", @"吴用", @"公孙胜", @"关胜", @"林冲", @"秦明" ,@"呼延灼" , @"花容",@"柴进", @"李应", @"朱仝",@"鲁智深",@"武松",nil]; } return self;}- (void)viewDidLoad { [super viewDidLoad]; // 系统默认的刷新, 下拉 self.RefreshControl = [[UIRefreshControl alloc] init]; self.RefreshControl.attributedTitle = [[NSAttributedString alloc] initWithString:@"正在刷新"]; [self.view addSubview:self.RefreshControl]; [self.RefreshControl addTarget:self action:@selector(changeVaule:) forControlEvents:UIControlEventValueChanged];}- (void)changeVaule:(UIRefreshControl *)refresh{ // 先关闭刷新效果, 若不关闭就会一直显示. [refresh endRefreshing]; NSString *str = @"哈哈"; [self.arr insertObject:str atIndex:0]; [self.tableView reloadData];}
这是创建文件时就已经写好的协议方法
#pragma mark - Table view data source- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {#warning Potentially incomplete method implementation. // Return the number of sections. return 1;}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {#warning Incomplete method implementation. // Return the number of rows in the section. return self.arr.count;}- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *reuse = @"reuse"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuse]; if (!cell) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:reuse] autorelease]; } cell.textLabel.text = self.arr[indexPath.row]; cell.textLabel.font = [UIFont systemFontOfSize:20]; // Configure the cell... return cell;}
当然, 协议中还有其他方法,比如, 有一个系统自带的快捷菜单
#pragma mark 设置是否允许给tableView上的cell添加快捷菜单方法.(协议中的)- (BOOL)tableView:(UITableView *)tableView shouldShowMenuForRowAtIndexPath:(NSIndexPath *)indexPath{ return YES;}#pragma mark 这个方法是设置是否允许给tableView的cell添加事件.- (BOOL)tableView:(UITableView *)tableView canPerformAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender{ return YES;}#pragma mark 当点击菜单上的按钮之后,会出现的方法.- (void)tableView:(UITableView *)tableView performAction:(SEL)action forRowAtIndexPath:(NSIndexPath *)indexPath withSender:(id)sender{ if (action == @selector(copy:)) { NSLog(@"copy"); }}
0 0
- UI 15 UITableViewController & 系统自带快捷菜单 & 系统下拉刷新
- 关于系统自带的下拉刷新
- Android开发-UI控件:为ListView,GirdView,etc...添加系统自带的下拉刷新功能
- 使用系统自带的 UIRefreshControl 实现下拉刷新
- 使用系统自带的 UIRefreshControl 实现下拉刷新
- 系统自带的UIRefreshControl下拉刷新的用法
- 使用Android系统自带的下拉刷新控件
- UITableView之(八):使用系统自带UIRefreshControl进行下拉刷新
- 自定义SwipeRefreshLayout实现上拉加载更多并自带系统的下拉刷新
- UIRefreshControl系统下拉刷新
- android 系统下拉刷新
- 哈04-xcode系统自带的刷新控件UIRefreshControl
- C# 美化WinForm窗体自带的系统菜单
- Android重写菜单增加系统自带返回键
- 仿华为系统自带天气预报UI---线条圆圈控件
- iOS tableView 自带的下拉刷新
- Android自带的下拉刷新控件
- android自带的下拉刷新
- hive mysql 编码问题
- noip2003 传染病控制 (深搜)
- 数据挖掘中所需的概率论与数理统计知识
- selenium webDriver 鼠标操作
- 织梦中自定义表单带*必填项的设置方法
- UI 15 UITableViewController & 系统自带快捷菜单 & 系统下拉刷新
- udig二次开发 eclipse环境搭建
- 【软考】——Java环境配置
- jquery选择器用法
- android平台led开发之内核硬件驱动层
- linux运行、关闭、查看后台任务
- PCIE协议解析 synopsys IP Register配置空间 读书笔记(8)
- ZOJ 3557-How Many Sets II(Lucas定理+插板法求组合数)
- 【转载】区间信息的维护与查询(一)——二叉索引树(Fenwick树、树状数组)