Peek and Pop新功能展示
2015-12-16 23:33
405 查看
//实现[b]UIViewControllerPreviewingDelegate代理方法[/b]
@interface InfoListTableViewController :
UITableViewController <UIViewControllerPreviewingDelegate>
@end
//
// InfoListTableViewController.m
// Test3DTouch
//
// Created by ios01 on 15/12/16.
// Copyright © 2015年 ios01. All rights reserved.
//
#import "InfoListTableViewController.h"
#import "InfoDetailViewController.h"
@interface
InfoListTableViewController ()
@property (nonatomic,
retain) NSMutableArray *arrDatas;
@property (strong,
nonatomic) IBOutlet
UITableView *showTableView;
@end
@implementation InfoListTableViewController
- (void)viewDidLoad {
[super
viewDidLoad];
[self setArrDatas:[NSMutableArray
arrayWithArray:@[@"1111",
@"2222"]]];
[_showTableView
reloadData];
[b]//
注册pep代理方法
[self
registerForPreviewingWithDelegate:self
sourceView:self.view];
// Uncomment the following line to preserve selection between presentations.
// self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)didReceiveMemoryWarning {
[super
didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
//#warning Incomplete implementation, return the number of sections
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//#warning Incomplete implementation, return the number of rows
NSLog(@"");
return [_arrDatas
count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier =
@"cellIdentifier";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:cellIdentifier];
// Configure the cell...
if (cell==nil) {
cell = [[UITableViewCell
alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier];
}
[cell.textLabel
setText:[_arrDatas
objectAtIndex:indexPath.row]];
return cell;
}
#pragma mark - peek和pop代理方法
//预览界面代理方法
- (UIViewController *)previewingContext:(id<UIViewControllerPreviewing>)context viewControllerForLocation:(CGPoint) point
{
InfoDetailViewController *childVC = [[InfoDetailViewController
alloc]
initWithNibName:@"InfoDetailViewController"
bundle:nil];
NSIndexPath* indexpath = [_showTableView
indexPathForRowAtPoint:point];
if (indexpath.row==0) {
[childVC setStrUrl:@"https://www.baidu.com"];
}
else {
[childVC setStrUrl:@"http://www.sina.com"];
}
// UIViewController *childVC = [[UIViewController alloc] init];
childVC.preferredContentSize =
CGSizeMake(0.0f,300.0f);
CGRect rect =
CGRectMake(10, point.y -
10, self.view.frame.size.width -
20,20);
context.sourceRect = rect;
return childVC;
}
//继续按压后,跳转到需要展示的界面
- (void)previewingContext:(id<UIViewControllerPreviewing>)context commitViewController:(UIViewController*)vc
{
[self
showViewController:vc sender:self];
}
@end
[/b]
相关文章推荐
- Ubuntu 平台下OpenResty的安装
- 用linux制作Mac OS U盘启动
- Linux--ftp 压缩,解压缩
- 关于动画培养灵感的网站
- linux C++/C 动态链接库使用
- [bigdata] hadoop 参数配置解析
- CentOS下安装Gitlab
- Linux初始化init系统
- Linux下Shell乘除加减运算
- Linux虚拟主机服务器一个空间多个网站以及其中.htaccess的重写
- Linux段页式管理思想--写操作系统内存管理必备知识,简单易懂
- linux基础命令
- eclipse提交subversion+apache的中文路径问题解决过程
- linux shell命令之read
- The Windows connection Linux question
- RMAN实战7:list、report命令、相关动态视图、shell对RMAN监控
- 常用dos命令(八)--COPY命令
- 在openwrt下对华为WA633无线AP的千兆网卡驱动进行支持
- 【Linux 驱动】异步通知机制
- Linux中find命令详解