GVKun编程网logo

ios – UICollectionView didSelectItemAtIndexPath在点击UITextView时未调用

4

对于想了解ios–UICollectionViewdidSelectItemAtIndexPath在点击UITextView时未调用的读者,本文将提供新的信息,并且为您提供关于iOS11下UIColl

对于想了解ios – UICollectionView didSelectItemAtIndexPath在点击UITextView时未调用的读者,本文将提供新的信息,并且为您提供关于iOS 11 下 UICollectionView 出现滚动条被 HeaderView 遮挡的问题、iOS 11 下 UICollectionView 的 HeaderView 遮挡滚动条、iOS 18发布啦!iOS 18好吗?iOS 18值得更新吗?iOS 18beta版、iOS 6.0 UICollectionView – 多次添加相同的单元格的有价值信息。

本文目录一览:

ios – UICollectionView didSelectItemAtIndexPath在点击UITextView时未调用

ios – UICollectionView didSelectItemAtIndexPath在点击UITextView时未调用

我有一个UICollectionView与自定义单元格 – 他们有一个UITextView,主要覆盖整个单元格.使用didSelectItemAtIndexPath时会出现此问题.触发它的唯一方法是点击UITextView外面.我想要它触发您点击的单元格中的任何位置,无论是否有文本视图.如何才能做到这一点?

解决方法

我建议使用UIGestureRecognizer为每个单元格,当它录音发送到UITextView或任何,也许可能有更好的解决方案,但我会使用这1因为简单的原因.

iOS 11 下 UICollectionView 出现滚动条被 HeaderView 遮挡的问题

iOS 11 下 UICollectionView 出现滚动条被 HeaderView 遮挡的问题

iOS 11 下 UICollectionView 出现滚动条被 HeaderView 遮挡的问题

在使用了- collectionView: viewForSupplementaryElementOfKind: atIndexPath:的 UICollectionView 页面中,滑动页面的时候滚动条会被 HeaderView 遮挡。导致滚动条看起来是断断续续的。

问题页面如下图所示(查看滚动条):

以上问题具体是否与使用了 - collectionView: viewForSupplementaryElementOfKind: atIndexPath: 有关目前还不确定,待验证。

这个问题在之前的 iOS 10 上是没有的,iOS 11 新出之后才出现。经过在 stackoverflow 上查找之后找到解决办法。https://stackoverflow.com/questions/46694144/scrollbar-incorrectly-appears-underneath-uicollectionview-section-header

stackoverflow 中提供的是 swift 中的解决办法,我自己则使用的是 Objective-C。

提示:解决这个问题只是更改了继承自 UICollectionReusableView 的自定义 HeaderView 类文件,所以这里只贴该自定义 HeaderView 的代码。

先看看在修复问题之前的 CustomHeaderView 类文件代码

// CustomHeaderView.h

#import <UIKit/UIKit.h>

extern NSString *const CustomHeaderViewReuseIdentifier;

@interface CustomHeaderView : UICollectionReusableView

@property (nonatomic, strong) UILabel *titleLabel;

@end


// CustomHeaderView.m
#import "CustomHeaderView.h"

NSString *const CustomHeaderViewReuseIdentifier = @"CustomHeaderView";

@implementation CustomHeaderView

- (void)layoutSubviews {
    [super layoutSubviews];
    [self createSubViews];
}

- (void)createSubViews {
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.textColor = [UIColor blackColor];
    CGFloat height = self.frame.size.height;
    _titleLabel.frame = CGRectMake(15, 0, 100, height);
    [self addSubview:_titleLabel];
}

@end

当为以上代码的时候,APP 在 iOS11 上运行就会出现上图的问题。 根据 stackoverflow 的提示更改代码之后,该问题便被修复。

以下为修复之后的CustomHeaderView类文件代码

// CustomHeaderView.h

#import <UIKit/UIKit.h>

extern NSString *const CustomHeaderViewReuseIdentifier;

#ifdef __IPHONE_11_0
@interface CustomLayer : CALayer

@end
#endif

@interface CustomHeaderView : UICollectionReusableView

@property (nonatomic, strong) UILabel *titleLabel;

@end


// CustomHeaderView.m
#import "CustomHeaderView.h"

NSString *const CustomHeaderViewReuseIdentifier = @"CustomHeaderView";

#ifdef __IPHONE_11_0
@implementation CustomLayer

- (CGFloat) zPosition {
    return 0;
}

@end
#endif

@implementation CustomHeaderView

- (void)layoutSubviews {
    [super layoutSubviews];
    [self createSubViews];
}

- (void)createSubViews {
    _titleLabel = [[UILabel alloc] init];
    _titleLabel.textColor = [UIColor blackColor];
    CGFloat height = self.frame.size.height;
    _titleLabel.frame = CGRectMake(15, 0, 100, height);
    [self addSubview:_titleLabel];
}

#ifdef __IPHONE_11_0
+ (Class)layerClass {
    return [CustomLayer class];
}
#endif

@end

以上代码相对于之前有问题的代码只是多了 #ifdef __IPHONE_11_0 ... #endif 之间的内容,使用 #ifdef __IPHONE_11_0 ... #endif母的是防止更改之后的代码在 iOS 10 上出现问题,从而确保更改只是针对 iOS11 及之后的版本有效。

更改之后的效果图如下所示:

iOS 11 下 UICollectionView 的 HeaderView 遮挡滚动条

iOS 11 下 UICollectionView 的 HeaderView 遮挡滚动条

这个问题在之前的 iOS 10 上是没有的,iOS 11 新出之后才出现。在使用了 - collectionView: viewForSupplementaryElementOfKind: atIndexPath: 的 UICollectionView 页面中,滑动页面的时候滚动条会被 HeaderView 遮挡.

 

#import "CustomCollectionReusableView.h"
#ifdef __IPHONE_11_0
@interface CustomLayer : CALayer
@end
#endif
@interface CustomCollectionReusableView ()
@property (nonatomic, strong) UILabel *showLabel;
/**< 显示控件 */
@end
#ifdef __IPHONE_11_0
@implementation CustomLayer - (CGFloat) zPosition { return 0; }
@end
#endif
@implementation CustomCollectionReusableView
- (void)layoutSubviews {
[super layoutSubviews];
[self _setUpSubViews];
}
- (void)_setUpSubViews {
[self addSubview:self.showLabel];
}
#pragma mark - Lazy
- (UILabel *)showLabel{
if (!_showLabel) {
_showLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 20, 120, self.frame.size.height)];
_showLabel.font = [UIFont systemFontOfSize:13];
_showLabel.textAlignment = NSTextAlignmentLeft;
_showLabel.backgroundColor = [UIColor clearColor];
_showLabel.textColor = [UIColor redColor]; } return _showLabel;
}
#ifdef __IPHONE_11_0
+ (Class)layerClass {
return [CustomLayer class];
}
#endif
@end


iOS 18发布啦!iOS 18好吗?iOS 18值得更新吗?iOS 18beta版

iOS 18发布啦!iOS 18好吗?iOS 18值得更新吗?iOS 18beta版

ios 18 横空出世,带来了一系列激动人心的新功能。您是否好奇 ios 18 的亮点,它是否值得升级?php小编西瓜带来 ios 18 的全面解读,详细介绍了它的新特性、改进和已解决的错误。如果您正在考虑升级到 ios 18,请继续阅读以了解它的优缺点,并决定它是否适合您的设备和需求。

iOS 18 beta版终于发布啦!iOS 18此次更新是否与预期一样呢? iOS 18更新了哪些内容呢?是否真的值得果粉用户升级呢?

iOS 18发布啦!iOS 18好吗?iOS 18值得更新吗?iOS 18beta版

iOS 18的更新内容涵盖了多个方面,旨在提升用户体验和个性化设置。以下是iOS 18的更新内容概览:

  • 定制主屏幕:

    • 用户可以自由移动应用程序,按照个人喜好调整主屏幕布局。

    • 图标支持深色模式,用户可以为图标着色,打造独特的外观。

    • 应用程序可以随意放置,深色模式APP有更深度的适配,且有色系可选,整体可调节成一种色系。

  • 优化控制中心:

    • 控制中心进行了重新设计,新增了多款快捷组件,用户可以根据需要选择和排列。

    • 控件页面支持多页布局,用户可滑动访问控制中心的其它页面。

    • 控制中心界面设计已扩展为多页布局,允许用户将不常访问的功能移动到次级页面。

  • 隐私与安全:

    • iOS 18支持给APP上锁,支持面容识别,同时也能隐藏APP,以加强用户的隐私权限。

    • 用户可以专门控制第三方App可以访问哪些通讯录,进一步保障数据安全。

  • 信息应用更新:

    • 发送的字体样式和表情有更多自定义选项。

    • 支持稍后发送功能。

    • 在无网情况下,iPhone 14及后续机型支持卫星直发。

  • 其他内置应用更新:

    • 邮箱应用进行了更新,分类和摘要功能提高了效率。

    • 钱包应用支持两个手机一碰即可相互转账。

    • 地图应用带来了新的地形图。

    • 相册应用引入了智能功能,查找照片和照片分类更加精准。

    附上iOS 18升级方法:

    ※1、刷机前请做好重要数据资料的备份,或勾选“保留用户资料刷机”,防止重要资料丢失;


    ※2、请确保移动设备未开启激活锁,或者知道 ID 锁帐号、密码,否则刷机后可能会无法激活设备;


    ※3、设备升级到 iOS 18后,将无法再降级到“苹果已关闭验证”的固件版本,即使之前使用备份了 SHSH 也不能降级。

    打开最新版电脑端,用数据线把手机设备连接到电脑。点击上方“智能刷机”进入到“一键刷机”界面,连接成功会自动匹配iOS 18固件,选择“保留用户资料刷机”立即刷机。

    iOS 18发布啦!iOS 18好吗?iOS 18值得更新吗?iOS 18beta版

    以上就是iOS 18发布啦!iOS 18好吗?iOS 18值得更新吗?iOS 18beta版的详细内容,更多请关注php中文网其它相关文章!

    iOS 6.0 UICollectionView – 多次添加相同的单元格

    iOS 6.0 UICollectionView – 多次添加相同的单元格

    在使用集合视图时,在cellforItemAtIndexPath中,即使将正确的reuseidentifier传递给“dequeueReusableCellWithReuseIdentifier:forIndexPath:”,也会在同一位置/帧上多次添加新的单元格实例(在另一个之上).

    上面提到的单元是UICollectionViewCell的子类,包含具有适当框架的UITextField.当滚动和文本字段是第一响应者时,上述问题正在发生.

    请让我知道解决问题的任何指示.

    解决方法

    这可能是UICollectionView中的一个错误,与我已经提交的 decoration views相关.只要您的单元格不透明,它就不会影响您的界面

    这可能(虽然,imo,不太可能)这对于UICollectionView来说是正确的行为,并且它使用那些额外的单元格来进行接口定向.无论如何,问题似乎不那么明显,那个装饰视图会增加几十个装饰视图的副本.只要它不影响你的应用程序,我会说它与它一起生活.

    关于ios – UICollectionView didSelectItemAtIndexPath在点击UITextView时未调用的介绍已经告一段落,感谢您的耐心阅读,如果想了解更多关于iOS 11 下 UICollectionView 出现滚动条被 HeaderView 遮挡的问题、iOS 11 下 UICollectionView 的 HeaderView 遮挡滚动条、iOS 18发布啦!iOS 18好吗?iOS 18值得更新吗?iOS 18beta版、iOS 6.0 UICollectionView – 多次添加相同的单元格的相关信息,请在本站寻找。

    本文标签: