AJ分享,必须精品

一:效果

后面的是xcode的控制台

二:代码

ViewController

#import "ViewController.h"
#import "ColorsViewController.h" @interface ViewController () <ColorsViewControllerDelegate, UIPopoverControllerDelegate>
- (IBAction)buttonClick:(UIButton *)btn;
@property (nonatomic, weak) UIButton *colorButton;
@property (nonatomic, strong) UIPopoverController *popover;
@property (weak, nonatomic) IBOutlet UIButton *greenButton; - (IBAction)greenButtonClick;
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; } - (IBAction)greenButtonClick {
NSLog(@"greenButtonClick");
} - (IBAction)buttonClick:(UIButton *)btn {
// 0.内容
ColorsViewController *colors = [[ColorsViewController alloc] init];
colors.delegate = self; // 1.创建
self.popover = [[UIPopoverController alloc] initWithContentViewController:colors];
self.popover.delegate = self; // 2.显示
// [self.popover presentPopoverFromRect:CGRectMake(150, 150, 100, 100) inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
[self.popover presentPopoverFromRect:CGRectMake(924, 668, 100, 100) inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
// [self.popover presentPopoverFromRect:btn.bounds inView:btn permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
// [self.popover presentPopoverFromRect:btn.frame inView:btn.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES]; // 3.设置哪里控件在popover显示出来的时候,仍旧可以跟用户进行交互
self.popover.passthroughViews = @[self.greenButton]; self.colorButton = btn;
} #pragma mark - 颜色选择代理
- (void)colorsViewController:(ColorsViewController *)vc didSelectColor:(UIColor *)color
{
self.colorButton.backgroundColor = color; // 关闭popover
[self.popover dismissPopoverAnimated:YES];
} #pragma mark - popover的代理
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController
{
NSLog(@"popover销毁了");
}
@end

ColorsViewController

#import <UIKit/UIKit.h>
@class ColorsViewController; @protocol ColorsViewControllerDelegate <NSObject> @optional
- (void)colorsViewController:(ColorsViewController *)vc didSelectColor:(UIColor *)color;
@end @interface ColorsViewController : UITableViewController
@property (nonatomic, weak) id<ColorsViewControllerDelegate> delegate;
@end
#import "ColorsViewController.h"

@interface ColorsViewController ()

@end

@implementation ColorsViewController

- (void)viewDidLoad {
[super viewDidLoad]; self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} #pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 30;
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *ID = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:ID];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
} cell.backgroundColor = [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1.0]; return cell;
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([self.delegate respondsToSelector:@selector(colorsViewController:didSelectColor:)]) {
UIColor *color = [tableView cellForRowAtIndexPath:indexPath].backgroundColor;
[self.delegate colorsViewController:self didSelectColor:color];
}
}
@end

AJ学IOS 之ipad开发Popover的调色板应用_popover显示后其他控件仍然能进行交互的更多相关文章

  1. AJ学IOS 之ipad开发Popover的基本使用

    AJ分享,必须精品 一:效果图 二:注意 对于方法[UIPopoverController dealloc] reached while popover is still visible. 当popo ...

  2. AJ学IOS 之ipad开发qq空间项目横竖屏幕适配

    AJ分享,必须精品 一:效果图 先看效果 二:结构图 如图所示: 其中用到了UIView+extension分类 Masonry第三方框架做子控制器的适配 NYHomeViewController对应 ...

  3. iPad开发--QQ空间,处理横竖屏布局,实现子控件中的代理

    一.主界面横竖屏效果图 二.主界面加载, 初始化Dock(红色框的控件),判断程序启动时的屏幕方向.调用自己- (void)transitionToLandScape:(BOOL)isLandScap ...

  4. AJ学IOS 之微博项目实战(10)微博cell中图片的显示以及各种填充模式简介

    AJ分享,必须精品 :一效果 如果直接设置会有拉伸等等的状况,这里主要介绍图片显示的一些细节 二:代码 代码实现其实很简单,微博当中用了一个photos来存放九宫格这些图片,然后用了一个photo类来 ...

  5. Winform开发中如何将数据库字段绑定到ComboBox控件

    最近开始自己动手写一个财务分析软件,由于自己也是刚学.Net不久,所以自己写的的时候遇到了很多问题,希望通过博客把一些印象深刻的问题记录下来. Winform开发中如何将数据库字段绑定到ComboBo ...

  6. Android开发系列(十八):自己定义控件样式在drawable目录下的XML实现

    在Android开发的过程中,我们常常须要对控件的样式做一下改变,能够通过用添加背景图片的方式进行改变,可是背景图片放多了肯定会使得APK文件变的非常大. 我们能够用自己定义属性shape来实现. s ...

  7. iOS - 初学iPad开发入门

    iPad是一款苹果公司于2010年发布的平板电脑定位介于苹果的智能手机iPhone和笔记本电脑MacBook产品之间跟iPhone一样,搭载的是iOS操作系统 iPhone和iPad开发的区别 屏幕的 ...

  8. iOS(iPhone,iPad))开发(Objective-C)开发库常用库索引

    http://www.code4app.com 这网站不错,收集各种 iOS App 开发可以用到的代码示例  http://www.cocoacontrols.com/ 英文版本的lib收集  ht ...

  9. AJ学IOS 之UIDynamic重力、弹性碰撞吸附等现象

    AJ分享,必须精品 一:效果 重力和碰撞 吸附现象 二:简介 什么是UIDynamic UIDynamic是从iOS 7开始引入的一种新技术,隶属于UIKit框架 可以认为是一种物理引擎,能模拟和仿真 ...

随机推荐

  1. hdu1045 炮台的配置 dfs

    只要炮台在同一行或者同一列,就可以互相摧毁,遇到墙则无法对墙后的炮台造成伤害,可以通过dfs搜索n*n的方格,全部搜完算一轮,计算炮台数,并保存其最大值. 其中对于t编号的炮台,位置可以计算出是(t/ ...

  2. Java——Collection集合

    ##Collection集合 1.Collection集合是单列集合 2.Collection是所有单列集合最顶层的接口,定义了所有单列集合的共性方法 任意的单列集合都可以使用Collection接口 ...

  3. F版本SpringCloud 4—Eureka注册中心开发和客户端开发

    源码地址:https://gitee.com/bingqilinpeishenme/Java-Tutorials 前言 通过前三篇文章,用大白话介绍了微服务和SpringCloud以及服务治理相关的概 ...

  4. 由最多N个给定数字集组成的数字 Numbers At Most N Given Digit Set

    2019-10-14 22:21:29 问题描述: 问题求解: 暴力求解必然会超时,那么就需要考虑数学的方法来降低时间复杂度了. public int atMostNGivenDigitSet(Str ...

  5. 使用Keras进行深度学习:(一)Keras 入门

    欢迎大家关注我们的网站和系列教程:http://www.tensorflownews.com/,学习更多的机器学习.深度学习的知识! Keras是Python中以CNTK.Tensorflow或者Th ...

  6. CSS常用属性之选择器

    css选择器 序号 选择器 例子 例子描述 1 .class .intro 选择class="intro"的所有元素 2 #id #firstname 选择id="fir ...

  7. 【python系统学习11】循环语句里的F4

    循环语句里的F4 深入了解下四个新语句,分别是:continue.break.pass.else以及他们搭配for.while循环等语句时,所产生的化学反应. else 由于continue.brea ...

  8. iOS 第三方库

    网络 AFNetworking HTTP网络库 Reachability 网络监测 UI.布局 Masonry AutoLayout SnapKit AutoLayout Swift TOWebVie ...

  9. Ubuntu虚拟机查看文件,目录颜色详解

    查看文件 查看Home(不是home)目录下文件: [duanyongchun@localhost ~]$ ls 查看根目录下文件: [duanyongchun@localhost ~]$ cd / ...

  10. Linux上的软件安装有哪些方式?

    Linux上的软件安装有以下几种常见方式介绍 1.二进制发布包 软件已经针对具体平台编译打包发布,只要解压,修改配置即可 2.RPM包 软件已经按照redhat的包管理工具规范RPM进行打包发布,需要 ...