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 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> 注意此方法不是万能的,比如:图文是内嵌型的就不适合这种方式

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调用保利威视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) { …

2019年 App Store Connect上传/更新应用时,App预览和屏幕快照规则更改

6 years ago 高效码农

最近在更新iOS APP版本时,按照之前的常规升级操作:添加版本信息->添加构建版本,居然提示: 所以查看了App预览和屏幕快照规则 之前的规则可以再下图中看到6.5英寸的屏幕快照是“可选的”,12.9 英寸(iPad Pro(第三代))也是可选的: 再来看现在最新的规则,可以看到6.5英寸的屏幕快照没有可选的字样: 总结:现在iOS app store中上传app需要的快照必须添加的屏幕尺寸有: 6.5 英寸(iPhone XS Max、iPhone XR) 5.5 英寸(iPhone 6s Plus、iPhone 7 Plus、iPhone 8 Plus) 12.9 英寸(iPad Pro(第三代)) 12.9 英寸(iPad Pro(第二代))

xcode报错:Multiple commands produce ‘…gold@3x.png’

6 years ago 高效码农

问题: :-1: Multiple commands produce ‘/Users/reanod/Library/Developer/Xcode/DerivedData/xxx-exvvnirkstuupfhewuknphwuveko/Build/Products/Debug-iphonesimulator/xxx.app/gold@3x.png’: 出错原因: 在xcode开发中,添加文件等资源使用的Create groups1.使用Create groups 当你选择了这个选项时,如果你想要引入的文件不在你的项目文件的目录下,Xcode则会自动将这个文件复制一份拷贝到你的项目的目录下 如果你不选择,并且这个文件也并不在你的项目目录下,那么这个文件仍然可以被使用,但是一旦你将项目拷贝到了别的地方时,这个文件就会找不到了。因为这个文件在你的电脑中,而不在你的项目中。 2.使用Create folder references方法 只是将文件单纯的创建了引用,这些文件不会被编译,所以在使用的时候需要加入其路径,比如在我们想要使用上图中的myScripts文件夹下面有某个头文件,则需要按照下面的方法添加声明: include myScripts/xxx.h 否则编译器就会告诉你找不到xxx.h文件。这就是项目中黄色文件夹与蓝色文件夹的区别以及使用方法所以:不建议❌使用【Create folder references】 3.建议使用如下方式添加资源 解决方法: 1.删除原来的资源2.重新添加资源