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 ...
随机推荐
- python 学习笔记6(数据库 sqlite)
26. SQLite 轻量级的关系型数据库 SQLite是python自带的数据库,可以搭配python存储数据,开发网站等. 标准库中的 sqlite3 提供该数据库的接口. 1. 基本语法如下 c ...
- Java多线程与并发库高级应用-传统线程互斥技术
线程安全问题: 多个线程操作同一份数据的时候,有可能会出现线程安全问题.可以用银行转账来解释. 模拟线程安全问题 /** * 启动两个线程分别打印两个名字,名字按照字符一个一个打印 * * @aut ...
- Leetcode 221. Maximal Square
本题用brute force超时.可以用DP,也可以不用. dp[i][j] 代表 以(i,j)为右下角正方形的边长. class Solution(object): def maximalSquar ...
- 【BZOJ-3667】Rabin_Miller算法 随机化判素数
3667: Rabin-Miller算法 Time Limit: 60 Sec Memory Limit: 512 MBSubmit: 983 Solved: 302[Submit][Status ...
- 【BZOJ-1717】Milk Patterns产奶的模式 后缀数组
1717: [Usaco2006 Dec]Milk Patterns 产奶的模式 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 881 Solved: ...
- C# 调用api的方法
问题场景: ASP.NET MVC Web API 定义 Post 方法,HttpClient 使用 JsonConvert.SerializeObject 传参进行调用,比如 Web Api 中定义 ...
- PHP数组/Hash表的实现/操作、PHP变量内核实现、PHP常量内核实现 - [ PHP内核学习 ]
catalogue . PHP Hash表 . PHP数组定义 . PHP变量实现 . PHP常量实现 1. PHP Hash表 0x1: 基本概念 哈希表在实践中使用的非常广泛,例如编译器通常会维护 ...
- ecshop /category.php SQL Injection Vul
catalog . 漏洞描述 . 漏洞触发条件 . 漏洞影响范围 . 漏洞代码分析 . 防御方法 . 攻防思考 1. 漏洞描述 Relevant Link: http://sebug.net/vuld ...
- POJ 3662 Telephone Lines(二分+最短路)
查看题目 最小化第K大值. 让我怀疑人生的一题目,我有这么笨? #include <cstdio> #include <queue> #include <cstring& ...
- MVC5-3 Result分析
众多的Result 使用MVC进行开发,可以看到有ActionResult.ContentReuslt.JsonResult..等,今天对这些Result进行背后分析.它到底是如何做到的 Action ...