UIPopoverController 的使用
#import "ViewController.h"
#import "RYColorSelectController.h"
#import "RYMenuViewController.h"
#import "RYTitleViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//设置菜单按钮
UIBarButtonItem *leftItem=[[UIBarButtonItem alloc]initWithTitle:@"菜单" style:UIBarButtonItemStylePlain target:self action:@selector(menuClick:)];
self.navigationItem.leftBarButtonItem=leftItem;
UIButton *btn=[[UIButton alloc]init];
[btn setTitle:@"主题" forState:UIControlStateNormal];
[btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
[btn sizeToFit];
self.navigationItem.titleView=btn;
[btn addTarget:self action:@selector(titleClick:) forControlEvents:UIControlEventTouchUpInside];
}
-(void)titleClick:(UIButton*)sender
{
RYTitleViewController *title=[[RYTitleViewController alloc]init];
title.view.backgroundColor=[[UIColor alloc]initWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1];
UIPopoverController* pop=[[UIPopoverController alloc]initWithContentViewController:title];
//第一种添加方式
[pop presentPopoverFromRect:sender.bounds inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
-(void)menuClick:(UIBarButtonItem*)sender
{
RYMenuViewController *title=[[RYMenuViewController alloc]init];
title.view.backgroundColor=[[UIColor alloc]initWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1];
UIPopoverController* pop=[[UIPopoverController alloc]initWithContentViewController:title];
//第二种添加方式
// //设置穿透哪些控件 当pop出来的控制器覆盖在其他的控件上的时候,设置被覆盖的控件也可以被点击
// selectColorPopover.passthroughViews = @[self.btnClick];
[pop presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
@end
#import <UIKit/UIKit.h>
@interface RYMenuViewController : UITableViewController
@end
#import "RYMenuViewController.h"
@interface RYMenuViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)NSArray *allData;
@end
@implementation RYMenuViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.dataSource=self;
self.tableView.delegate=self;
///设置展示界面大小
self.preferredContentSize = CGSizeMake(100, 200);
}
-(NSArray*)allData
{
if (_allData==nil) {
_allData=@[@"博客",@"好友",@"拖拉机",@"shangpin"];
}
return _allData;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return self.allData.count;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString*inderface=@"cell";
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:inderface];
if (!cell) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:inderface];
}
cell.textLabel.text=self.allData[indexPath.row];
return cell;
}
@end
#import <UIKit/UIKit.h>
@interface RYTitleViewController : UIViewController
@end
#import "RYTitleViewController.h"
@interface RYTitleViewController ()
@end
@implementation RYTitleViewController
- (void)viewDidLoad {
[super viewDidLoad];
///设置展示界面大小
self.preferredContentSize = CGSizeMake(100, 100);
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
UIPopoverController 的使用的更多相关文章
- 《简单的自定义DropDatePicker》-- UIPopoverController 和 代理 以及 Block 实现。
最近做项目为了方便项目使用,自定义的空间 写的比较粗糙.欢迎大家批评指正.以上为在项目中的实际应用 // DropDownDatePicker.h // DropDownDatePickerDemo ...
- UIPopoverController使用
*:first-child { margin-top: 0 !important; } body > *:last-child { margin-bottom: 0 !important; } ...
- iPad 控件UIPopoverController使用
UIPopoverController 是iPad特有控件,(iOS7-9),在iOS9之后别废弃 使用步骤 设置内容控制器 UIPopoverController直接继承NSObject,不具备可视 ...
- QQ空间HD(2)-UIPopoverController其它使用
DJTestViewController.m #import "DJTestViewController.h" #import "DJColorTableViewCont ...
- QQ空间HD(1)-UIPopoverController基本使用
UIPopoverController 是iPad的专属API ViewController.m #import "ViewController.h" #import " ...
- iOS iPad开发之UIPopoverController的使用
1. 什么是UIPopoverController? 是iPad开发中常见的一种控制器(在iphone上不允许使用) 跟其他控制器不一样的是,它直接继承自NSObject,并非继承自UIViewCon ...
- iOS:弹出窗控制器:UIPopoverController
弹出窗控制器:UIPopoverController 截图: 实质:就是将内容控制器包装成popoverController的形式,然后在模态出来,必须给定指向目标(target.frame). ...
- iOS:iPad和iPhone开发的异同(UIPopoverController、UISplitViewController)
iPad和iPhone开发的异同 1.iPhone和iPad: niPhone是手机,iPad.iPad Mini是平板电脑 iPhone和iPad开发的区别 屏幕的尺寸 \分辨率 UI元素的排布 \ ...
- iOS- iPad UIPopoverController
在IPAD开发中,有一个很有趣的视图控制器,UIPopoverControllr,它的初始化必须要设置一个"内容视图",相当于它本身只是作为一个“容器”,而显示的内容还需要另外一个 ...
随机推荐
- poj 1442
一个排序的题目. 题意:给你m个数a[m],和n个数b[n]. 首先a[0]….a[b[0]]排序.输出第一个数. 然后a[0]….a[b[1]]排序.输出第二个数. 以此类推,直到输出第n个数. 思 ...
- redis与memcache区别总结
2015年9月2日 14:04:19 总会被问到两者的区别, 在这里总结下: redis 有内置的多种数据结构, list(可用于实现小型队列), hash, set, zset...; memcac ...
- Zookeeper服务常用的操作命令
Zookeeper服务安装之后,一般会在这个服务的基础之上安装其他的大数据平台,其他的框架一般会提供很多接口对Zookeeper中的内容进行一定的操作,但是功能相对单一,所以有些时候,有必要我们自己登 ...
- ffmpeg-20160517-git-bin
ESC 退出 0 进度条开关 1 屏幕原始大小 2 屏幕1/2大小 3 屏幕1/3大小 4 屏幕1/4大小 S 下一帧 [ -2秒 ] +2秒 ; -1秒 ' +1秒 下一个帧 -> -5秒 f ...
- 7.SpringMVC注解优化
新建controller,每个人都可以建自己的controller,比较方便,不用再在web.xml中进行配置,value的请求地址一定要唯一. 优化: 1.上面示例中spring-annotatio ...
- Linux实时流量监控工具 - iftop
*本文转自ggjucheng的博客 介绍 iftop是一款实时流量监控工具,监控TCP/IP连接等,缺点就是无报表功能.必须以root身份才能运行. 实例 默认是监控第一块网卡的流量 iftop 监控 ...
- 在wpf中使用winrt的Toast弹框效果
源码地址:https://code.msdn.microsoft.com/windowsdesktop/Sending-toast-notifications-71e230a2/sourcecode? ...
- telnet测试制定地址端口号
cmd下,命令 telnel+空格+ip或者网站+空格+端口号 端口可以用: 需要开通windows服务:
- 【leetcode】Rotate Image(middle)
You are given an n x n 2D matrix representing an image. Rotate the image by 90 degrees (clockwise). ...
- 【leetcode】3Sum (medium)
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all un ...