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,它的初始化必须要设置一个"内容视图",相当于它本身只是作为一个“容器”,而显示的内容还需要另外一个 ...
随机推荐
- 使用宏批量将多个csv文件转成excel文件
在一个压缩文件中有100多个csv文件,要求要将此100多个csv文件转成excel文件,名字命名不变,有三种方式: 1. 傻不拉几的复制粘贴法 2. 一个一个打开csv文件,另存为xls文件,工作量 ...
- python virtualenv环境运行django
python virtualenv环境运行django 安装前准备 检查pip版本与python版本是否一致 [root@localhost bin]# whereis pip pip: /usr/b ...
- C++ 中超类化和子类化常用API
在windows平台上,使用C++实现子类化和超类化常用的API并不多,由于这些API函数的详解和使用方法,网上一大把.本文仅作为笔记,简单的记录一下. 子类化:SetWindowLong,GetWi ...
- 使用Java中File类批量创建文件和批量修改文件名
批量创建文件 int cont = 1; String s = "E:\\学习资料\\Java笔记-"; while(cont<100){ File f = new File ...
- SSM 加载配置文件
配置文件中 <bean id="address" class="org.springframework.beans.factory.config.Propertie ...
- Android实现Banner界面广告图片循环轮播(包括实现手动滑动循环)
前言:经常会看到有一些app的banner界面可以实现循环播放多个广告图片和手动滑动循环.本以为单纯的ViewPager就可以实现这些功能.但是蛋疼的事情来了,ViewPager并不支持循环翻页.所以 ...
- September 8th 2016 Week 37th Thursday
The secret of high-impact business is early preparation. 高效商务,赢在未雨绸缪. Early and best preparation is ...
- 解决springmvc 前台取不到值
查看web.xml 如果为web-app_2_3.xsd spring不支持 修改项目为web-app_2_4.xsd
- C/C++中调用python文件
1.将python27安装目录下include.libs文件夹拷贝至Demo程序目录. 2.Demo项目设置包含Python.h.python27.lib); (因为安装python27的时候,pyt ...
- Java 配色方案--Dark Flash Builder - by Wilson Silva
http://eclipsecolorthemes.org/?view=theme&id=1855