macOS Sequoia 15.0 无法访问局域网 IP网站

6 months ago 高效码农

一、报错信息 无法访问 http://192.168.10.199:5173/。 ERR_ADDRESS_UNREACHABLE 解决方案 在设置-隐私与安全性-本地网络里打开 Google Chrome 的本地网络权限。(注意2个都需要打开)打开后一定点击浏览器地址栏回车键,点击浏览器刷新按钮不管用。 2024年12月12日更新 系统更新到macOS Sequoia 15.2后设置-隐私与安全性-本地网络里打开 Google Chrome 的本地网络权限 也不管用了;暂时解决方案是使用Safari浏览器 2024年12月17日更新 1.今天找到了解决方案! 2.关闭 Chrome 应用并确保它没有运行。 3.然后进入您的应用程序文件夹并将 Chrome 应用重命名为 Chrome Temp。 4.然后双击 Chrome Temp 再次重新打开 Chrome。 5.然后尝试访问本地网络上的地址 6.然后系统会再次提示您是否允许 Chrome 访问您的本地网络。请批准访问本地网络。 7.再次关闭 Chrome 应用 8.返回“应用程序”文件夹并将“Chrome Temp”重命名为“Chrome”

苹果开发者个人开发者账号转企业账号

9 months ago 高效码农

个人开发者账号转企业账号,因为不是法人,苹果也不允许修改账号信息,跟我说只能新申请企业账号,然后走App转让。 申请了企业账号,付费成功,走转让程序,跟我说无法转让,意思是用了App Group,App Group是个啥呢? 只要你做桌面小组件,你就需要共享你的数据给小组件,不然小组件无法显示App内数据,这是苹果的官方手段,但是用了,你的App就再也无法转移了。 给的解决方案是新账号下新建App,然后自己重新发布,历史数据和历史用户全部丢失

在SwiftUI 应用程序中添加谷歌开屏广告Admob Open Ad

2 years ago 高效码农

1、新建一个OpenAd类:(记得导入GoogleMobileAds) final class OpenAd: NSObject, GADFullScreenContentDelegate { var appOpenAd: GADAppOpenAd? var loadTime = Date() func requestAppOpenAd() { let request = GADRequest() GADAppOpenAd.load(withAdUnitID: "ca-app-pub-3940256099942544/5662855259", request: request, orientation: UIInterfaceOrientation.portrait, completionHandler: { (appOpenAdIn, _) in self.appOpenAd = appOpenAdIn self.appOpenAd?.fullScreenContentDelegate = self self.loadTime = Date() print("[OPEN AD] Ad is ready") }) } func tryToPresentAd() { if let gOpenAd = self.appOpenAd, wasLoadTimeLessThanNHoursAgo(thresholdN: 4) { gOpenAd.present(fromRootViewController: (UIApplication.shared.windows.first?.rootViewController)!) } else { self.requestAppOpenAd() } } func wasLoadTimeLessThanNHoursAgo(thresholdN: Int) -> Bool { let now = Date() let timeIntervalBetweenNowAndLoadTime = now.timeIntervalSince(self.loadTime) let secondsPerHour = 3600.0 let intervalInHours = timeIntervalBetweenNowAndLoadTime / secondsPerHour return intervalInHours < Double(thresholdN) } func ad(_ ad: GADFullScreenPresentingAd, …

如何在 iOS、MacOS 上使用 ChatGPT 和适用于 iPhone 的最佳 ChatGPT 应用程序

2 years ago 高效码农

目录 什么是聊天 GPT? 如何在我的 iPhone 上使用 ChatGPT? 适用于 iPhone 的最佳 ChatGPT 应用程序 在过去的几周里,出现了许多 ChatGPT 应用程序和网站。如果您想了解什么是 ChatGPT、如何在 iOS 上使用它以及适用于 iOS 的最佳 ChatGPT 应用程序是什么,请访问我的博客。 什么是ChatGPT? 了解 GPT-3:在过去的两年中,您可能已经看到了许多 GPT-3 AI 编写器网络应用程序。GPT 3(Generative Pre-trained Transformer 3)是由 OpenAI 创建的语言模型。它经过训练可以生成看似由人类书写的文本。 在这里,你需要提供一些单词或句子作为提示,AI 会从那里继续完成信息。互联网上有很多 AI 写作网站,您可以尝试一下。 现在 OpenAI 已经创建了ChatGPT。这是一个 AI 聊天机器人,经过训练可以回答您的任何问题,甚至比 Google 还要好。它可以提供最新的趋势和新闻,帮助您编码,解决您的数学问题,甚至可以为您写一首诗。您可以在 iPhone/iOS 上使用 ChatGPT。 在这里,我已经通俗易懂地解释了。维基百科是这样定义 ChatGPT的: “ChatGPT 是 OpenAI 开发的人工智能聊天机器人原型,专门从事对话。” 聊天机器人是一种大型语言模型,采用监督学习和强化学习技术进行了微调。“它是 OpenAI 的 GPT-3.5 语言模型家族中模型的微调版本。” 如何在我的 iPhone 上使用 ChatGPT? 你可以在任何 iPhone 上使用这个 AI 聊天机器人,无论你使用的是什么 iOS 版本。在 iOS 上使用 ChatGPT 可以方便地在移动环境中访问 OpenAI 强大的文本生成 AI。 设置帐户简单明了,登录后即可立即开始使用聊天机器人。以下是在 iOS 上使用 ChatGPT 的分步指南: 1. 在 APP Store搜索或者直接点击:AI-ChatGPThttps://apps.apple.com/us/app/ai-chatgpt-免注册免登录ai智能聊天/id1660346816 2. 下载打开APP后分为聊天和内容补全: 3. 应用开发者内置了apikey可以直接使用 4. 如果出现返回中提示填写apikey在首页右上角添加apikey。 概括 ChatGPT 还提供高级功能,例如对话构建工具、分析和自定义集成。这些功能可以帮助您改进和改进您的自然语言处理。 而已!您现在拥有开始在 iOS 上使用 ChatGPT 所需的所有信息。

swift开发常见问题汇总

3 years ago 高效码农

一、tabBarItem.selectedImage 设置选中图片无效 修改前代码 my.tabBarItem.selectedImage = UIImage(named: "my_selected") 修改后代码 解决方案:增加渲染方式.alwaysOriginal my.tabBarItem.selectedImage = UIImage(named: "my_selected")?.withRenderingMode(.alwaysOriginal) 二、报错信息:because they have no common ancestor. Does the constraint or its anchors reference items in different view hierarchies? That’s illegal. 解决方案:将子视图在约束之前添加到主视图中 三、导入自定义字体无效 导入方法:https://juejin.cn/post/6844903529623060488 如果按照步骤还是无效验证一下:是否和现有字体冲突;验证方法为将字体加入到字体册出现上图说明字体冲突 四、UIView加圆角 layer.cornerRadius 不管用 解决方案:视图上的子视图,如果超出父视图的部分就截取掉,即设置 UIView.clipsToBounds = true 五、报错信息:Trailing closure passed to parameter of type ‘Visibility’ that does not acce 解决方案: 1、查看是否{ ( 是否关闭;2、查看.toolbar { 是否有过期代码

swiftUI APP 集成 Google 移动广告 Admob (二)

3 years ago 高效码农

书接上文 ~~~~ 激励广告 创建激励广告几乎与插页式广告相同。唯一的区别是,对于奖励广告,我们需要创建一个函数,该函数将在授予奖励时运行。 就像插页式广告一样,我们需要创建一个RewardedAdObject来处理广告的加载。 class RewardedAd: NSObject { var rewardedAd: GADRewardedAd? static let shared = RewardedAd() func loadAd(withAdUnitId id: String) { let req = GADRequest() GADRewardedAd.load(withAdUnitID: id, request: req) { rewardedAd, err in if let err = err { print("Failed to load ad with error: \(err)") return } self.rewardedAd = rewardedAd } } } 现在,我们将使用这个对象来创建RewardedAdView。 class RewardedAdView: NSObject, UIViewControllerRepresentable, GADFullScreenContentDelegate { let rewardedAd = RewardedAd.shared.rewardedAd @Binding var isPresented: Bool let adUnitId: String //This is the variable for our reward function let rewardFunc: (() -> Void) init(isPresented: Binding<Bool>, adUnitId: String, rewardFunc: @escaping (() -> Void)) { self._isPresented = isPresented self.adUnitId …

SwiftUI APP 集成 Google 移动广告 Admob (一)

3 years ago 高效码农

简介: 随着越来越多的应用程序使用 SwiftUI 构建,我想提供一种简单的方法将 Admob 直接集成到您的应用程序中。为了让大家集成的更容易,我计划将它作为 Cocoapod 发布。 先看一下集成后的效果: 设置 Google 移动广告 (Admob) SDK 申请应用,请参考 Google 的官方文档地址为:https://developers.google.com/admob/ios/quick-start。 使用 Cocoapods 导入 SDK pod ‘Google-Mobile-Ads-SDK’ 然后使用命令行运行 pod install –repo-update 更新 Info.plist 请更新应用的 Info.plist 文件以添加以下两个键: 一个字符串值为您的 AdMob 应用 ID 的 GADApplicationIdentifier 键(在 AdMob 界面中标识)。 一个 SKAdNetworkIdentifier 值为 Google(cstr6suwn9.skadnetwork),并选择向 Google 提供了这些值的其他买家的 SKAdNetworkItems 键。 <key>GADApplicationIdentifier</key> <string>ca-app-pub-3940256099942544~2435281174</string> 初始化 Google 移动广告 (Admob) SDK import SwiftUI import AppTrackingTransparency import GoogleMobileAds @main struct ExampleApp: App { //在 App Delegate 中使用 init() 代替 ApplicationDidFinishLaunchWithOptions init() { if ATTrackingManager.trackingAuthorizationStatus == .notDetermined { // TODO 这里可以弹出隐私协议 } else { ATTrackingManager.requestTrackingAuthorization { status in GADMobileAds.sharedInstance().start(completionHandler: nil) } } } var body: some Scene …

SwiftUI 开发问题集锦

3 years ago 高效码农

开发环境: xcode版本:13.1 swift版本:5.5.1 swift-driver version: 1.26.9 Apple Swift version 5.5.1 一、缺少文件: 问题: 创建新项目后缺少了 AppDelegate.swift、SceneDelegate.swift 文件,那么在初始化一些SDK时,无法初始化 解决方案: 在项目App.swift文件中加入init()方法: @main struct SwiftUIExampleApp: App { init() { // 可以在这里做初始化的操作 } var body: some Scene { WindowGroup { ContentView() } } } 二、找不到Info.plist文件 问题: 在需要往info.plist文件中添加值时,找不到info.plist文件 解决方案: info.plist 文件改为了xcode的配置,位置向导为;Project → Targets → Info → Custom iOS Target Properties 三、报错信息:Non-constant range: not an integer range 解决方案: 传递一个id参数 原因Apple官方解释: /// Creates an instance that generates Rotor content by combining, in order, /// individual Rotor content for each element in the data given to this /// `ForEach`. /// /// It’s important that the `id` of a data element …

Vapor安装教程问题集锦

3 years ago 高效码农

简介: Vapor 是 Swift 最常用的 Web 框架。这是一个适用于 macOS 和 Ubuntu 的 Swift 网络框架。 安装错误❌ : 1、要在 macOS 上使用 Vapor,您只需要安装 Xcode 9.3 或更高版本。 2、swift build –disable-sandbox -c release -Xswiftc -cross-module-optimization 在执行到 brew install vapor/tap/vapor 会报各种github库超时错误:如LibreSSL SSL_connect: Operation timed out in connection to github.com:443 解决方案: 1、配置git全局代理: # 设置当前代理 git config –global http.proxy http://127.0.0.1:**自己的端口号** git config –global https.proxy https://127.0.0.1:**自己的端口号** # 取消当前代理 git config –unset http.proxy #取消全局代理 git config –global –unset http.proxy #设置socks5代理 git config http.proxy socks5://127.0.0.1:**自己的端口号** 2、设置终端代理: # 修改shell配置文件 ~/.bashrc ~/.zshrc等 export http_proxy=socks5://127.0.0.1:1081 export https_proxy=$http_proxy 3、 再次执行brew install vapor/tap/vapor brew install vapor/tap/vapor 创建Hello项目时,一路选n Cloning template… name: Hello Would you like to use Fluent? …

HTSDCycleScrollView 更新到iOS14后,图片偏移,且无法手动滑动

4 years ago 高效码农

一、问题:使用HTSDCycleScrollView后在升级iOS14后出现: 更新到iOS14后,图片偏移,且无法手动滑动 二、解决方案: 在导入的SDCycleScrollView.m文件setupMainView方法中添加: if(@available(iOS 14.0, *)){ mainView.pagingEnabled = NO; } else{ mainView.pagingEnabled = YES; } 三、原理 isPagingEnabled属性:如果该属性的值为true,当用户滚动时,滚动视图在滚动视图边界的倍数处停止。默认值为false。

swift学习笔记

4 years ago 高效码农

文章只是根据自身情况,记录swift语言和其他语言的区别,请勿对号入座,请根据自身情况选择性学习: 一、类型注解 注意:类型注解作为一个需要了解的知识点,不做深入研究,因为在项目实操中很少需要写类型注解;理由是:Swift 可以推断出常量或者变量的类型 当你声明常量或者变量的时候可以加上类型注解(type annotation),说明常量或者变量中要存储的值的类型。如果要添加类型注解,需要在常量或者变量名后面加上一个冒号和空格,然后加上类型名称。 var x:String 声明中的冒号代表着“是…类型”,所以这行代码可以被理解为: “声明一个类型为 String ,名字为 x 的变量。” “类型为 String ”的意思是“可以存储任意 String 类型的值。” x 变量现在可以被设置成任意字符串: x = "高效码农" print(x) 完整代码: var x:String x = "高效码农" print(x) 你可以在一行中定义多个同样类型的变量,用逗号分割,并在最后一个变量名之后添加类型注解: var red, green, blue: Double 二、整数 Swift提供的整数类型有:Int、Int8、Int16、Int32、Int64、UInt、UInt8、UInt16、UInt32、UInt64 带U的为无符号整数; 除非你需要特定长度的整数,一般来说使用 Int 就够了。这可以提高代码一致性和可复用性。即使是在32位平台上,Int 可以存储的整数范围也可以达到 -2,147,483,648 ~ 2,147,483,647,大多数时候这已经足够大了。 三、类型别名 类型别名(type aliases)就是给现有类型定义另一个名字。你可以使用 typealias 关键字来定义类型别名。 typealias exmple = UInt32 var typeExmple = exmple.max 本例中,exmple 被定义为 UInt32 的一个别名。因为它是别名,exmple.min 实际上是 UInt32.max ,所以会给 typeExmple 赋一个初值 4294967295。 项目实操中没有用到过这个特性,在其他语言实战中也没有遇到有类似需求的场景,不知道干啥用的; 四、可选类型 声明一个可选常量或者变量 var surveyAnswer: String? print(surveyAnswer) // surveyAnswer 被自动设置为 nil Swift 的 nil 和 Objective-C 中的 nil 并不一样。在 Objective-C 中,nil 是一个指向不存在对象的指针。在 Swift 中,nil 不是指针——它是一个确定的值,用来表示值缺失。任何类型的可选状态都可以被设置为 nil,不只是对象类型。 五、可选绑定 在Swift中,返回值或者数据类型后面加 ?表示可选类型,值可以为空,但是后面加 …

iOS 复选框 BEMCheckBox 使用教程

4 years ago 高效码农

效果展示: 使用方式: 1、Podfile中引入: pod ‘BEMCheckBox’ 2、执行以下命令: pod install 3、在需要使用的类中引入: #import "BEMCheckBox.h" 4、添加代理协议: BEMCheckBoxDelegate 5、实例化BEMCheckBox //********************** 用户协议 ************** BEMCheckBox *userAagreement = [[BEMCheckBox alloc] init]; userAagreement.delegate = self; userAagreement.boxType = BEMBoxTypeSquare; [self.view addSubview:userAagreement]; 6、代理协议的实现方法: – (void)didTapCheckBox:(BEMCheckBox *)checkBox{ NSLog(@"%@", checkBox.on ? @"YES":@"NO"); } 属性 ‘on’ 允许你检索和设置(无动画)一个值来确定BEMCheckBox 对象 on 或 off。 默认为 NO。逻辑可以判断checkBox.on后执行

iOS object-c 小技巧

4 years ago 高效码农

一、iOS12版本 使用reloadRowsAtIndexPaths方法 刷新cell 界面抖动/跳动 解决方法: __strong typeof(self) strongSelf = self; [UIView performWithoutAnimation:^{ CGPoint loc = self.tableView.contentOffset; [self.tableView reloadRowsAtIndexPaths:@[self.indexPath] withRowAnimation:UITableViewRowAnimationFade]; strongSelf.tableView.contentOffset = loc; }]; 二、A界面跳转到B界面,操作后返回A界面刷新单个组件(view,cell) 解决方案:在B界面重写返回按钮事件: – (void)backBtnClicked{ [self.view endEditing:YES]; [NSObject cancelPreviousPerformRequestsWithTarget:self]; UIViewController *ctl = self.navigationController.viewControllers[self.navigationController.viewControllers.count – 2]; if ([ctl isKindOfClass:[QAListViewController class]]) { QAListViewController *QAVC = (QAListViewController *)ctl; QAVC.questionID = self.questionID; QAVC.is_upate = YES; self.answerModel.like_type = [NSString stringWithFormat:@"%ld", (long)self.answerModel.good_bad]; QAVC.answerModel = self.answerModel; [self.navigationController popToViewController:QAVC animated:YES]; }else{ [self.navigationController popViewControllerAnimated:YES]; } } 在A界面定义变量:是否需要更新is_update,以及更新的内容在A界面的生命周期viewWillAppear中判断: – (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; if (self.is_upate) { [self.newsDataArray replaceObjectAtIndex:self.cellIndexPath.row withObject:self.answerModel]; __strong typeof(self) strongSelf = self; [UIView performWithoutAnimation:^{ CGPoint loc = self.tableView.contentOffset; [self.tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:self.cellIndexPath,nil] withRowAnimation:UITableViewRowAnimationFade]; strongSelf.tableView.contentOffset = loc; }]; self.is_upate …

iOS DTCoreText 加载html富文本 pod 集成方式

5 years ago 高效码农

由于项目中后台文章是用富文本编辑器保存的html代码,iOS端需要展示html的富文本;所以测试使用DTCoreText控件,但是最后因为图片加载失败导致崩溃,没有使用;特此记录。 一、pod方式集成: 在Podfile文件中添加 # 富文本显示 pod ‘DTCoreText’ 在项目目录下: pod install 二、编写代码 在使用的类中或者在宏定义文件中引入: #import <DTCoreText/DTCoreText.h> 代码简单测试: NSString *html = @"<a>https://www.xugj520.cn/</a>"; NSData *data = [html dataUsingEncoding:NSUTF8StringEncoding]; NSAttributedString *attrString = [[NSAttributedString alloc] initWithHTMLData:data documentAttributes:NULL]; NSLog(@"%@", attrString); 详细使用介绍:https://docs.cocoanetics.com/DTCoreText/ 三、出现的问题: 1、当远程图片无法加载时,程序崩溃;2、当html代码超过5000左右的字符时会出现 Warning: A DTAttributedLabel with size {964, 1764} is using a non-tiled layer. Set the layer class to a CATiledLayer subclass with [DTAttributedTextContentView setLayerClass:[DTTiledLayerWithoutFade class]] 3、不知道是我前端技术不过关还是iOS对H5新增标签不支持(如:section、article)感觉是将seciton变为了div;有懂的希望留言赐教~~~

iOS UILabel,UITableViewCell 显示html 图文混合

5 years ago 高效码农

直接代码: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; } cell.textLabel.numberOfLines = 0; UIFont *font=[UIFont systemFontOfSize:14]; NSDictionary *optoins=@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType, NSFontAttributeName:font}; NSData *data=[self.lectorContent dataUsingEncoding:NSUnicodeStringEncoding]; NSAttributedString *attributeString=[[NSAttributedString alloc] initWithData:data options:optoins documentAttributes:nil error:nil]; cell.textLabel.attributedText=attributeString; return cell; } 备注:当图片超出屏幕时,可以在html代码中添加样式如: <head><style>img{width:%f !important;height:auto}</style></head> 注意此方法不是万能的,比如:图文是内嵌型的就不适合这种方式

PYSearch中的searchHistoryView消失

5 years ago 高效码农

PYSearch特征 ✅ 支持多种热搜风格 ✅ 支持多种搜索历史样式 ✅ 支持多种搜索结果显示方式 ✅ 支持多种搜索视图控制器显示模式 ✅ 支持搜索建议 ✅ 支持搜索历史(记录)缓存 ✅ 使用委托或块完成搜索支持回调 ✅ 支持CocoaPods ✅ 支持本地化 ✅ 在iPhone和iPad上支持垂直和水平屏幕 PYSearch使用 使用CocoaPods: pod "PYSearch" 导入主文件:#import <PYSearch.h> 手动导入: 拖动文件PYSearch夹中的所有文件进行投影 导入主文件:#import “PYSearch.h” PYSearch中的searchHistoryView消失 并且用Lookin查看searchHistoryView消失(非隐藏) 先看演示效果正常:异常: 问题解决: 在项目中查找 设备结束旋转通知endGeneratingDeviceOrientationNotifications 方法注释掉 /** * 结束 设备旋转通知 * * @return return value description */ [[UIDevice currentDevice]endGeneratingDeviceOrientationNotifications];

友盟SDK精简版和完整版区别

5 years ago 高效码农

微信(精简版):微信精简版在原生SDK基础上做了深度精简和优化,不含微信支付及微信统计功能,只包含分享及第三方平台登录(授权)功能微信(完整版):完整版功能完全与第三方平台提供的原生SDK相同 QQ(精简版):精简版是在原生SDK基础上做了深度精简、优化,只包含分享及第三方登录(授权)功能QQ(完整版):完整版功能完全与第三方平台提供的原生SDK相同 新浪微博(精简版):精简版是在原生SDK基础上做了深度精简和优化,只包含分享及第三方平台登录(授权)功能新浪微博(完整版):完整版功能完全与第三方平台提供的原生SDK相同 iOS集成友盟SDK示例: # U-Share SDK UI模块(分享面板,建议添加) pod ‘UMCShare/UI’ # 集成微信(精简版0.2M) pod ‘UMCShare/Social/ReducedWeChat’ # 集成微信(完整版14.4M) pod ‘UMCShare/Social/WeChat’ # 集成QQ/QZone/TIM(精简版0.5M) pod ‘UMCShare/Social/ReducedQQ’ # 集成QQ/QZone/TIM(完整版7.6M) pod ‘UMCShare/Social/QQ’ # 集成新浪微博(精简版1M) pod ‘UMCShare/Social/ReducedSina’ # 集成新浪微博(完整版25.3M) pod ‘UMCShare/Social/Sina’ # 集成Facebook/Messenger pod ‘UMCShare/Social/Facebook’ # 集成Twitter pod ‘UMCShare/Social/Twitter’ # 集成支付宝 pod ‘UMCShare/Social/AlipayShare’ # 集成钉钉 pod ‘UMCShare/Social/DingDing’ # 集成豆瓣 pod ‘UMCShare/Social/Douban’ # 集成人人 pod ‘UMCShare/Social/Renren’ # 集成腾讯微博 pod ‘UMCShare/Social/TencentWeibo’ # 集成易信 pod ‘UMCShare/Social/YiXin’ # 集成Flickr pod ‘UMCShare/Social/Flickr’ # 集成Kakao pod ‘UMCShare/Social/Kakao’ # 集成Tumblr pod ‘UMCShare/Social/Tumblr’ # 集成Pinterest pod ‘UMCShare/Social/Pinterest’ # 集成Instagram pod ‘UMCShare/Social/Instagram’ # 集成Line pod ‘UMCShare/Social/Line’ # 集成WhatsApp pod ‘UMCShare/Social/WhatsApp’ # 集成有道云笔记 pod ‘UMCShare/Social/YouDao’ # 集成印象笔记 …

iOS UITableView中的HeaderSection、FooterSection不悬浮、停留 设置

5 years ago 高效码农

方式一: 修改tableView的style为UITableViewStyleGrouped 如: self.tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStylePlain]; 方式二:(普遍推荐) 在创建tableView之后(同时设置HeaderSection、FooterSection) self.headerViewHeight = 30; self.footerViewHeight = 5; self.tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.headerViewHeight)]; self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.footerViewHeight)]; self.tableView.contentInset = UIEdgeInsetsMake(-self.headerViewHeight, 0, -self.footerViewHeight, 0); 在创建tableView之后(设置HeaderSection) self.headerViewHeight = 30; self.tableView.tableHeaderView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.headerViewHeight)]; self.tableView.contentInset = UIEdgeInsetsMake(-self.headerViewHeight, 0, 0, 0); 在创建tableView之后(设置FooterSection) self.footerViewHeight = 5; self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, self.footerViewHeight)]; self.tableView.contentInset = UIEdgeInsetsMake(0, 0, -self.footerViewHeight, 0);

swift导入OC版QMUI SDK

5 years ago 高效码农

一、xcode11 新建swift5 项目 参考:https://www.xugj520.cn/archives/xcode-swift.html 二、接入 SDK 在项目目录下执行 $ pod init 在 Podfile 中指定: pod ‘QMUIKit’ 在项目目录终端下执行: $ pod install 三、新建桥接的头文件 并添加到 四、在头文件中导入 #import <QMUIKit/QMUIKit.h> 五、在swift文件中使用QMUI import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() self.title = "aaa" self.view.backgroundColor = UIColor(hue: 0.50, saturation: 0.20, brightness: 0.86, alpha: 1.00) let button = QMUIButton(); button.frame = CGRect(x: 10, y: 210, width: 300, height: 50) button.backgroundColor = UIColor.red button.addTarget(self, action: #selector(buttonClick), for: .touchUpInside) self.view.addSubview(button) } @objc func buttonClick(){ print("被点击了") } }

swift调用保利威视SDK(polyv-ios-vod-sdk)

5 years ago 高效码农

一、xcode11 新建swift5 项目 参考Xcode11新建低版本iOS,swift项目流程及问题 二、接入 SDK 在项目目录下执行 $ pod init 在 Podfile 中指定: pod ‘PolyvVodSDK’ pod ‘PLVVodDanmu’ pod ‘PLVSubtitle’ pod ‘FDStackView’ pod ‘Masonry’ pod ‘YYWebImage’ 在项目目录终端下执行: $ pod install 三、将播放器空间和皮肤等资源引入到项目 复制PolyvOpenSourceModule文件夹到你的项目 复制PLVNetworkUtil.h和PLVNetworkUtil.m文件到新项目 四、新建OC文件和桥接文件,点播初始化 点播初始化: 在OC文件中添加方法 polyvInit PLVDemo.h文件中添加 -(void)polyvInit; PLVDemo.m文件中添加 /** 初始化保利威视 */ -(void)polyvInit{ NSError *error = nil; PLVVodSettings *settings = [PLVVodSettings settingsWithConfigString:@"yQRmgnzPyCUYDx6weXRATIN8gkp7BYGAl3ATjE/jHZunrULx8CoKa1WGMjfHftVChhIQlCA9bFeDDX+ThiuBHLjsNRjotqxhiz97ZjYaCQH/MhUrbEURv58317PwPuGEf3rbLVPOa4c9jliBcO+22A==" key:@"VXtlHmwfS2oYm0CZ" iv:@"2u9gDPKdX6GyQJKU" error:&error]; // 读取并替换设置项。出于安全考虑,不建议从 plist 读取加密串,直接在代码中写入加密串更为安全。 { NSUserDefaults *user = [NSUserDefaults standardUserDefaults]; BOOL enableUserVodKey = [user boolForKey:PLVApplySettingKey]; if (enableUserVodKey) { NSString *userVodKey = [user stringForKey:PLVVodKeySettingKey]; userVodKey = [userVodKey stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; if (userVodKey.length) { settings = [PLVVodSettings settingsWithConfigString:userVodKey error:&error]; } } } NSLog(@"settings: %@", settings); if (error) { …