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,它的初始化必须要设置一个"内容视图",相当于它本身只是作为一个“容器”,而显示的内容还需要另外一个 ...
随机推荐
- Shell 读取文本内容
在Linux中有很多方法逐行读取一个文件的方法,其中最常用的就是下面的脚本里的方法,而且是效率最高,使用最多的方法.为了给大家一个直观的感受,我们将通过生成一个大的文件的方式来检验各种方法的执行效率. ...
- Spring MVC配置静态资源的正常访问
SpringMVC如果过滤器过滤范围配置了/或者/*,那么框架会过滤所有请求,包括自己写的请求和静态资源请求,这样静态资源就不能正常加载,包括js文件.css文件.图片资源访问的时候都会出现404页面 ...
- Java for LeetCode 209 Minimum Size Subarray Sum
Given an array of n positive integers and a positive integer s, find the minimal length of a subarra ...
- 省市县联动dropdownlist
下面就是在提交按钮的单击事件中填写代码(代码区)(前提是把省市县的数据库建好) protected void Page_Load(object sender, EventArgs e) ...
- java入门 第一季3
运算符:算术运算符,赋值运算符,比较运算符,逻辑运算符,条件运算符 1. 算术运算符: 自增和自减只能用于操作变量,不能直接用于操作数值和常量 % 求余数 2. 赋值运算符 = 赋值运算符为变量或常 ...
- MySQL 获得当前日期时间\时间戳 函数 ( 转自传智播客)
MySQL 获得当前日期时间 函数 1.1 获得当前日期+时间(date + time)函数:now() mysql> select now(); +-------+ | now() | +-- ...
- sqlserver insert 存储过程
-- 根据表中数据生成insert语句的存储过程Create Proc proc_insert (@tablename varchar(256)) as ...
- iOS 中CoreData的简单使用
原文链接:http://www.jianshu.com/p/4411f507dd9f 介绍:本文介绍的CoreData不在AppDelegate中创建,在程序中新建工程使用,即创建本地数据库,缓存数据 ...
- Sql如何自动定时备份数据库
直接上图
- EF性能调优
首先说明下: 第一次运行真是太慢了,处理9600多个员工数据,用了81分钟!! 代码也挺简单,主要是得到数据-->对比分析-->插入分析结果到数据库.用的是EF的操作模式. public ...