QQ空间HD(1)-UIPopoverController基本使用
UIPopoverController 是iPad的专属API
ViewController.m
#import "ViewController.h"
#import "DJMenuViewController.h" @interface ViewController () - (IBAction)leftItemDidClick:(id)sender; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} - (IBAction)leftItemDidClick:(id)sender { DJMenuViewController *menuVC = [[DJMenuViewController alloc] init];
UINavigationController *menuNavVC = [[UINavigationController alloc] initWithRootViewController:menuVC]; // 创建一个popoverController,注意!只能使用initWithContentViewController创建!
// 在iOS7以下的系统中,需要将popoverVC当做一个成员变量,使用一个强指针进行引用,否则在这段代码执行完毕后,popoverVC将被销毁
UIPopoverController *popoverVC = [[UIPopoverController alloc] initWithContentViewController:menuNavVC];
// 设置popoverController的内部尺寸
popoverVC.popoverContentSize = CGSizeMake(, *);
// 显示popoverController,有点类似于android里面的popview的showAsDropDown方法
[popoverVC presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; }
@end
DJMenuViewController.m
#import "DJMenuViewController.h"
#import "DJTestViewController.h" @interface DJMenuViewController() @property (nonatomic,strong) NSArray *titles; @end @implementation DJMenuViewController - (void)viewDidLoad { [super viewDidLoad];
self.titles = @[@"发起群聊",@"添加朋友",@"扫一扫",@"收付款"]; } - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return self.titles.count;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *ID = @"title";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
} cell.textLabel.text = self.titles[indexPath.row];
return cell;
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { DJTestViewController *testVC = [[DJTestViewController alloc] init];
[self.navigationController pushViewController:testVC animated:YES]; } @end
DJTestViewController.m
#import "DJTestViewController.h" @implementation DJTestViewController - (void)viewDidLoad { [super viewDidLoad]; self.view.backgroundColor = [UIColor redColor];
} @end
Main.stroyboard
最终运行效果:
QQ空间HD(1)-UIPopoverController基本使用的更多相关文章
- QQ空间HD(2)-UIPopoverController其它使用
DJTestViewController.m #import "DJTestViewController.h" #import "DJColorTableViewCont ...
- QQ空间HD(6)-实现自定义的选项卡切换效果
DJTabbarButton.m #import "DJTabbarButton.h" @implementation DJTabbarButton - (instancetype ...
- QQ空间HD(5)-添加左侧菜单栏内容
DJIconView.m #import "DJIconView.h" @implementation DJIconView - (instancetype)initWithFra ...
- QQ空间HD(4)-设置左侧菜单栏属性
DJHomeViewController.m #import "DJHomeViewController.h" #import "DJMenuView.h" ; ...
- QQ空间HD(3)-Modal的切换效果总结
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { UIViewController ...
- iOS开发UI篇—模仿ipad版QQ空间登录界面
iOS开发UI篇—模仿ipad版QQ空间登录界面 一.实现和步骤 1.一般ipad项目在命名的时候可以加一个HD,标明为高清版 2.设置项目的文件结构,分为home和login两个部分 3.登陆界面的 ...
- QQ空间动态爬虫
作者:虚静 链接:https://zhuanlan.zhihu.com/p/24656161 来源:知乎 著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明出处. 先说明几件事: 题目的意 ...
- 仿QQ空间根据位置弹出PopupWindow显示更多操作效果
我们打开QQ空间的时候有个箭头按钮点击之后弹出PopupWindow会根据位置的变化显示在箭头的上方还是下方,比普通的PopupWindow弹在屏幕中间显示好看的多. 先看QQ空间效果图: ...
- QQ空间/朋友圈类界面的搭建
类似于QQ空间的布局主要是在说说信息.点赞.回复三大部分的自适应布局上. 当我们需要搭建类似QQ空间.微信朋友圈的界面的时候,可做如下操作: 创建一个对应的model类: 创建一个对应model类的f ...
随机推荐
- 匿名内部类为什么访问外部类局部变量必须是final的?
1.内部类里面使用外部类的局部变量时,其实就是内部类的对象在使用它,内部类对象生命周期中都可能调用它,而内部类试图访问外部方法中的局部变量时,外部方法的局部变量很可能已经不存在了,那么就得延续其生命, ...
- 一次性下载CVPR2016的所有文章
wget --no-clobber --convert-links --random-wait -r -p -E -e robots=off -U mozilla http://www.cv-foun ...
- 【BZOJ-3709】Bohater 贪心
3709: [PA2014]Bohater Time Limit: 5 Sec Memory Limit: 128 MBSec Special JudgeSubmit: 835 Solved: ...
- 基于Maven引入Hadoop包报Missing artifact jdk.tools:jdk.tools:jar:1.6
一.问题来源 <dependency> <groupId>org.apache.hadoop</groupId> <artifactId>hadoop- ...
- SPOJ GSS2 Can you answer these queries II
Time Limit: 1000MS Memory Limit: 1572864KB 64bit IO Format: %lld & %llu Description Being a ...
- Mysql Index、B Tree、B+ Tree、SQL Optimization
catalog . 引言 . Mysql索引 . Mysql B/B+ Tree . Mysql SQL Optimization . MySQL Query Execution Process 1. ...
- oracle创建存储过程
创建: create or replace procedure insert_tbuser ( username nvarchar2,usersex nvarchar2,userage numbe ...
- Socket与SocketServer结合多线程实现多客户端与服务器通信
需求说明:实现多客户端用户登录,实现多客户端登录一般都需要使用线程技术: (1)创建服务器端线程类,run()方法中实现对一个请求的响应处理: (2)修改服务器端代码,实现循环监听状态: (3)服务器 ...
- JavaWeb学习总结-07 Filter 学习和使用
一 Filter简介 Filter也称之为过滤器,它是Servlet技术中最激动人心的技术,WEB开发人员通过Filter技术,对web服务器管理的所有web资源:例如Jsp, Servlet, 静态 ...
- 关于 客户端发现响应内容类型为“text/html; charset=utf-8”,但应为“text/xml”的解决方法
http://www.cnblogs.com/jams742003/archive/2008/10/30/1322761.html 请求web服务时,会有如题的异常出现,解决方法如下: 1 检查web ...