iOS TableVew 侧滑效果~ OC语言~demo
2017-08-21 11:51
387 查看
//联系人:石虎
QQ: 1224614774昵称:嗡嘛呢叭咪哄
/**
注意点: 1.看 GIF 效果图.
2.看连线视图的效果图.
3.看实现代码(直接复制实现效果).
*/
一、GIF 效果图:
二、连线视图的效果图:
图1:
三、实现代码:
=============
======================================
控制器1: ViewController.m
//
// ViewController.m
// TableVew 侧滑效果~ OC语言
//
// Created by 石虎 on 2017/8/21.
// Copyright © 2017年 shihu. All rights reserved.
//
#import "ViewController.h"
@interface
ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView
*tableView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
_tableView = [[UITableViewalloc]initWithFrame:CGRectMake(0,60,self.view.frame.size.width
, self.view.frame.size.height)];
_tableView.backgroundColor = [UIColororangeColor];
_tableView.delegate =self;
_tableView.dataSource =self;
_tableView.rowHeight =80;
[self.tableViewregisterClass:[UITableViewCellclass]forCellReuseIdentifier:@"CELL"];
[self.viewaddSubview:_tableView];
}
#pragma mark -- 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
// cell 的唯一标识符
staticNSString *ider =@"CELL";
//创建 cell
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:iderforIndexPath:indexPath];
//缓存池
if (!cell) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:ider];
}
//赋值内容
cell.textLabel.text = [NSStringstringWithFormat:@"row
--- %ld",(long)indexPath.row];
//cell 的背景颜色
cell.backgroundColor = [UIColoryellowColor];
return cell;
}
#pragma mark -- 代理方法
//这个方法就是可以自己添加一些侧滑出来的按钮,并执行一些命令和按钮设置
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(nonnullNSIndexPath
*)indexPath
{
//设置按钮(它默认第一个是修改系统的)
UITableViewRowAction *actionOne = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleNormaltitle:@"我是第一个"handler:^(UITableViewRowAction
*_Nonnull action,NSIndexPath *_Nonnull indexPath) {
NSLog(@"我是第一个----->");
[[[UIAlertViewalloc]initWithTitle:@"提醒"message:@"我是第一个点击成功"delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil]
show];
}];
//设置按钮(它默认第一个是修改系统的)
UITableViewRowAction *actionTwo = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"我是第二个"handler:^(UITableViewRowAction
*_Nonnull action,NSIndexPath *_Nonnull indexPath) {
//执行跳转到下个界面操作
NSLog(@"我是第二个----->");
[[[UIAlertViewalloc]initWithTitle:@"提醒"message:@"我是第二个点击成功"delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil]
show];
}];
actionOne.backgroundColor = [UIColorblueColor];
actionTwo.backgroundColor = [UIColorredColor];
return@[actionOne,actionTwo];
}
@end
===============
=======
谢谢!!!
QQ: 1224614774昵称:嗡嘛呢叭咪哄
/**
注意点: 1.看 GIF 效果图.
2.看连线视图的效果图.
3.看实现代码(直接复制实现效果).
*/
一、GIF 效果图:
二、连线视图的效果图:
图1:
三、实现代码:
=============
======================================
控制器1: ViewController.m
//
// ViewController.m
// TableVew 侧滑效果~ OC语言
//
// Created by 石虎 on 2017/8/21.
// Copyright © 2017年 shihu. All rights reserved.
//
#import "ViewController.h"
@interface
ViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong)UITableView
*tableView;
@end
@implementation ViewController
- (void)viewDidLoad {
[superviewDidLoad];
_tableView = [[UITableViewalloc]initWithFrame:CGRectMake(0,60,self.view.frame.size.width
, self.view.frame.size.height)];
_tableView.backgroundColor = [UIColororangeColor];
_tableView.delegate =self;
_tableView.dataSource =self;
_tableView.rowHeight =80;
[self.tableViewregisterClass:[UITableViewCellclass]forCellReuseIdentifier:@"CELL"];
[self.viewaddSubview:_tableView];
}
#pragma mark -- 数据源方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return10;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath
*)indexPath
{
// cell 的唯一标识符
staticNSString *ider =@"CELL";
//创建 cell
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:iderforIndexPath:indexPath];
//缓存池
if (!cell) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:ider];
}
//赋值内容
cell.textLabel.text = [NSStringstringWithFormat:@"row
--- %ld",(long)indexPath.row];
//cell 的背景颜色
cell.backgroundColor = [UIColoryellowColor];
return cell;
}
#pragma mark -- 代理方法
//这个方法就是可以自己添加一些侧滑出来的按钮,并执行一些命令和按钮设置
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(nonnullNSIndexPath
*)indexPath
{
//设置按钮(它默认第一个是修改系统的)
UITableViewRowAction *actionOne = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleNormaltitle:@"我是第一个"handler:^(UITableViewRowAction
*_Nonnull action,NSIndexPath *_Nonnull indexPath) {
NSLog(@"我是第一个----->");
[[[UIAlertViewalloc]initWithTitle:@"提醒"message:@"我是第一个点击成功"delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil]
show];
}];
//设置按钮(它默认第一个是修改系统的)
UITableViewRowAction *actionTwo = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"我是第二个"handler:^(UITableViewRowAction
*_Nonnull action,NSIndexPath *_Nonnull indexPath) {
//执行跳转到下个界面操作
NSLog(@"我是第二个----->");
[[[UIAlertViewalloc]initWithTitle:@"提醒"message:@"我是第二个点击成功"delegate:nilcancelButtonTitle:@"确定"otherButtonTitles:nil]
show];
}];
actionOne.backgroundColor = [UIColorblueColor];
actionTwo.backgroundColor = [UIColorredColor];
return@[actionOne,actionTwo];
}
@end
===============
=======
谢谢!!!
相关文章推荐
- [IOS TableView]--3D效果的StackBoxDemoFree
- iOS侧滑效果Demo
- iOS 侧滑菜单封装Demo(类似QQ侧滑效果)
- iOS TableVew 侧滑效果~ Swift语言~demo
- iOS开发(OC)——QQ点赞效果
- [demo]仿IOS底部弹框效果及Android各类对话框和弹框效果
- iOS状态栏效果 指示器 开源框架 附有Demo
- IOS开发---OC语言-㉜NSString字符串
- AJ学IOS(26)UI之iOS抽屉效果小Demo
- iOS OC语言: Block底层实现原理
- iOS开发-OC语言 (七)继承、多态、类别
- [置顶] ios 网页中图片点击放大效果demo
- 黑马训练营--IOS学习---OC语言学习总结2
- 蓝鸥iOS从零基础到精通就业-OC语言入门 属性1
- iOS 实现刮刮乐效果demo剑客篇(欢迎提建议和分享经验)
- iOS下用一行代码实现tableview(collectionview)的parallax效果
- 蓝鸥iOS从零基础到精通就业-OC语言入门 字典
- iOS - OC 语言新特性
- 黑马程序员IOS-OC语言-构造方法
- ios之TableView实现上下拉动刷新效果