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,它的初始化必须要设置一个"内容视图",相当于它本身只是作为一个“容器”,而显示的内容还需要另外一个 ...
随机推荐
- vim python设置
http://www.cnblogs.com/Leo-Forest/archive/2012/04/06/2435237.html http://linux-wiki.cn/wiki/zh-hans/ ...
- Semaphore(信号量)
Semaphore msdn介绍: 限制可同时访问某一资源或资源池的线程数. 命名空间: System.Threading 程序集: System(在 System.dll 中) 通俗理解: 1:宾馆 ...
- FastReport中文网
FastReport中文网 http://www.fastreportcn.com/Article/2.html
- WPS文字在表格中打字自动跳动
可以设置表格的属性来实现. 1.选择表格,点击鼠标右键,选择“表格属性” 2.在出现的对话框中,文字环绕选择“无”,“行”的设置为“允许跨页断行”,就可以了.
- vector在C++中的基本用法
在写BlackJackGame的时候,考虑到要用到容器,所以就对容器的相关知识强化了一下: 因为我想的是有card类,最后要实现发牌,洗牌等等一系列的操作的时候,使用指向card类的对象的指针,将ca ...
- 【ACM】hud1166 敌兵布阵(线段树)
经验: cout 特别慢 如果要求速度 全部用 printf !!! 在学习线段树 内容来自:http://www.cnblogs.com/shuaiwhu/archive/2012/04/22/24 ...
- 【python】f.write()写入中文出错解决办法
一个出错的例子 #coding:utf-8 s = u'中文' f = open("test.txt","w") f.write(s) f.close() 原因 ...
- 解决SQL Server的cannot resolve the collation conflict问题
当没有牵涉到两个不同的数据库时,出现以上错误. Cannot resolve the collation conflict between "Chinese_PRC_CI_AS" ...
- iOS获取状态栏和导航栏尺寸(宽度和高度)
iPhone开发当中,有时需要获取状态栏和导航栏高度.宽度信息,方便布局其他控件.下面介绍一下如何获取这些信息: // 状态栏(statusbar) CGRect rectStatus = [[UIA ...
- n数乘积第m小
这是从Java贴吧看到的一道面试题,看了别人的解题思路实现的.... 如题: n个数,他们的乘积可得到一些其它的数,求第m小的. 输入格式: n m n1 n2 n3 ... 例: 输入: 3 8 2 ...