猫猫学iOS之ipad开发Popover的调色板应用_popover显示后其他控件仍然能进行交互

本文主要是介绍猫猫学iOS之ipad开发Popover的调色板应用_popover显示后其他控件仍然能进行交互,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

猫猫分享,必须精品

原创文章,欢迎转载。转载请注明:翟乃玉的博客
地址:http://blog.csdn.net/u013357243

一:效果

后面的是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

这篇关于猫猫学iOS之ipad开发Popover的调色板应用_popover显示后其他控件仍然能进行交互的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1138332

相关文章

Java Stream流之GroupBy的用法及应用场景

《JavaStream流之GroupBy的用法及应用场景》本教程将详细介绍如何在Java中使用Stream流的groupby方法,包括基本用法和一些常见的实际应用场景,感兴趣的朋友一起看看吧... 目录Java Stream流之GroupBy的用法1. 前言2. 基础概念什么是 GroupBy?Stream

python中列表应用和扩展性实用详解

《python中列表应用和扩展性实用详解》文章介绍了Python列表的核心特性:有序数据集合,用[]定义,元素类型可不同,支持迭代、循环、切片,可执行增删改查、排序、推导式及嵌套操作,是常用的数据处理... 目录1、列表定义2、格式3、列表是可迭代对象4、列表的常见操作总结1、列表定义是处理一组有序项目的

PyQt5 GUI 开发的基础知识

《PyQt5GUI开发的基础知识》Qt是一个跨平台的C++图形用户界面开发框架,支持GUI和非GUI程序开发,本文介绍了使用PyQt5进行界面开发的基础知识,包括创建简单窗口、常用控件、窗口属性设... 目录简介第一个PyQt程序最常用的三个功能模块控件QPushButton(按钮)控件QLable(纯文本

C#中的Converter的具体应用

《C#中的Converter的具体应用》C#中的Converter提供了一种灵活的类型转换机制,本文详细介绍了Converter的基本概念、使用场景,具有一定的参考价值,感兴趣的可以了解一下... 目录Converter的基本概念1. Converter委托2. 使用场景布尔型转换示例示例1:简单的字符串到

Spring Boot Actuator应用监控与管理的详细步骤

《SpringBootActuator应用监控与管理的详细步骤》SpringBootActuator是SpringBoot的监控工具,提供健康检查、性能指标、日志管理等核心功能,支持自定义和扩展端... 目录一、 Spring Boot Actuator 概述二、 集成 Spring Boot Actuat

PyTorch中的词嵌入层(nn.Embedding)详解与实战应用示例

《PyTorch中的词嵌入层(nn.Embedding)详解与实战应用示例》词嵌入解决NLP维度灾难,捕捉语义关系,PyTorch的nn.Embedding模块提供灵活实现,支持参数配置、预训练及变长... 目录一、词嵌入(Word Embedding)简介为什么需要词嵌入?二、PyTorch中的nn.Em

Spring Boot3.0新特性全面解析与应用实战

《SpringBoot3.0新特性全面解析与应用实战》SpringBoot3.0作为Spring生态系统的一个重要里程碑,带来了众多令人兴奋的新特性和改进,本文将深入解析SpringBoot3.0的... 目录核心变化概览Java版本要求提升迁移至Jakarta EE重要新特性详解1. Native Ima

一文解密Python进行监控进程的黑科技

《一文解密Python进行监控进程的黑科技》在计算机系统管理和应用性能优化中,监控进程的CPU、内存和IO使用率是非常重要的任务,下面我们就来讲讲如何Python写一个简单使用的监控进程的工具吧... 目录准备工作监控CPU使用率监控内存使用率监控IO使用率小工具代码整合在计算机系统管理和应用性能优化中,监

如何使用Lombok进行spring 注入

《如何使用Lombok进行spring注入》本文介绍如何用Lombok简化Spring注入,推荐优先使用setter注入,通过注解自动生成getter/setter及构造器,减少冗余代码,提升开发效... Lombok为了开发环境简化代码,好处不用多说。spring 注入方式为2种,构造器注入和setter

基于Python开发一个图像水印批量添加工具

《基于Python开发一个图像水印批量添加工具》在当今数字化内容爆炸式增长的时代,图像版权保护已成为创作者和企业的核心需求,本方案将详细介绍一个基于PythonPIL库的工业级图像水印解决方案,有需要... 目录一、系统架构设计1.1 整体处理流程1.2 类结构设计(扩展版本)二、核心算法深入解析2.1 自