如何在故事板中使用UICollectionViewController,同时仍支持ios 5.1?

时间:2021-10-21 03:54:15

It is a best practice to detect if a certain feature's class exists and degrade user's features depending on availability. I created UICollectionView in storyboard and a standard tableview to support ios 5.1 users. I then simply check if the user has this feature and segue to the appropriate scene. However, when I now try to compile my code I get a "dyld: Symbol not found: _UICollectionElementKindSectionHeader" This seems very anti-pattern of apple to not allow ios6.0 features in storyboard with a ios 5.1 deployment target.

最佳实践是检测某个功能的类是否存在,并根据可用性降低用户的功能。我在故事板中创建了UICollectionView,并在标准的tableview中创建了ios 5.1用户。然后我只是检查用户是否具有此功能并转到相应的场景。但是,当我现在尝试编译我的代码时,我得到一个“dyld:未找到符号:_UICollectionElementKindSectionHeader”这似乎非常反模式的苹果不允许ios6.0功能在故事板中具有ios 5.1部署目标。

if ([UICollectionView class]) {
    [self performSegueWithIdentifier:@"UserShow" sender:self];
} else {
    [self performSegueWithIdentifier:@"UserShowTable" sender:self];
}

The above seems like a pretty reasonable approach to me...

上面对我来说似乎是一个非常合理的方法......

3 个解决方案

#1


2  

You can't. As soon as you drop the collections view controller to the storyboard, it will try to reference it automatically, what will result in the compilation error you've got.

你不能。只要将集合视图控制器拖放到故事板,它就会尝试自动引用它,这将导致您获得的编译错误。

#2


3  

I know this is not proper to put only link answers but her it is not possible to include the whole files.

我知道仅仅放置链接答案是不恰当的,但她不可能包含整个文件。

Please see this.

请看这个。

A controller is designed to provide the same functionality as UICollectionController of iOS 6 but still supports to iOS 4/5

控制器旨在提供与iOS 6的UICollectionController相同的功能,但仍支持iOS 4/5

What developer is telling

开发人员在说什么

PSTCollectionView
Open Source, 100% API compatible replacement of UICollectionView for iOS4.3+

PSTCollectionView开源,100%API兼容替代UICollectionView for iOS4.3 +

You want to use UICollectionView, but still need to support iOS4/5? Then you'll gonna love this project. I've originally written it for PSPDFKit, my iOS PDF framework that supports text selection and annotations, but this project seemed way to useful for others to to keep it for myself :) Plus, I would love the influx of new gridviews to stop. Better just write layout managers and build on a great codebase.

你想使用UICollectionView,但仍然需要支持iOS4 / 5?然后你会爱上这个项目。我最初是为PSPDFKit编写的,我的iOS PDF框架支持文本选择和注释,但是这个项目似乎对其他人有用,可以为自己保留它:)另外,我希望新网格视图的涌入能够停止。最好只编写布局管理器并构建一个优秀的代码库。

The goal is to use PSTCollectionView on iOS 4/5 as a fallback and switch to UICollectionView on iOS6. We even use certain runtime tricks to create UICollectionView at runtime for older versions of iOS. Ideally, you just link the files and everything works on older systems. Practically, it's not that easy, and especially when you're using subclasses of UICollectionView-classes, since they can't be replaced at runtime.

目标是在iOS 4/5上使用PSTCollectionView作为后备并切换到iOS6上的UICollectionView。我们甚至使用某些运行时技巧在运行时为旧版本的iOS创建UICollectionView。理想情况下,您只需链接文件,一切都可以在旧系统上运行。实际上,它并不那么容易,尤其是当您使用UICollectionView类的子类时,因为它们无法在运行时替换。

#3


2  

There's no compatibility solution for pre-6.0 deployment via storyboards, but PSTCollectionView does support iOS 5.0+ and is actively maintained. It does work at runtime to use UICollectionView* on 6.0 and later, and should be storyboard compatible.

没有通过故事板进行6.0之前部署的兼容性解决方案,但PSTCollectionView确实支持iOS 5.0+并且得到了积极维护。它在运行时可以在6.0及更高版本上使用UICollectionView *,并且应该与storyboard兼容。

#1


2  

You can't. As soon as you drop the collections view controller to the storyboard, it will try to reference it automatically, what will result in the compilation error you've got.

你不能。只要将集合视图控制器拖放到故事板,它就会尝试自动引用它,这将导致您获得的编译错误。

#2


3  

I know this is not proper to put only link answers but her it is not possible to include the whole files.

我知道仅仅放置链接答案是不恰当的,但她不可能包含整个文件。

Please see this.

请看这个。

A controller is designed to provide the same functionality as UICollectionController of iOS 6 but still supports to iOS 4/5

控制器旨在提供与iOS 6的UICollectionController相同的功能,但仍支持iOS 4/5

What developer is telling

开发人员在说什么

PSTCollectionView
Open Source, 100% API compatible replacement of UICollectionView for iOS4.3+

PSTCollectionView开源,100%API兼容替代UICollectionView for iOS4.3 +

You want to use UICollectionView, but still need to support iOS4/5? Then you'll gonna love this project. I've originally written it for PSPDFKit, my iOS PDF framework that supports text selection and annotations, but this project seemed way to useful for others to to keep it for myself :) Plus, I would love the influx of new gridviews to stop. Better just write layout managers and build on a great codebase.

你想使用UICollectionView,但仍然需要支持iOS4 / 5?然后你会爱上这个项目。我最初是为PSPDFKit编写的,我的iOS PDF框架支持文本选择和注释,但是这个项目似乎对其他人有用,可以为自己保留它:)另外,我希望新网格视图的涌入能够停止。最好只编写布局管理器并构建一个优秀的代码库。

The goal is to use PSTCollectionView on iOS 4/5 as a fallback and switch to UICollectionView on iOS6. We even use certain runtime tricks to create UICollectionView at runtime for older versions of iOS. Ideally, you just link the files and everything works on older systems. Practically, it's not that easy, and especially when you're using subclasses of UICollectionView-classes, since they can't be replaced at runtime.

目标是在iOS 4/5上使用PSTCollectionView作为后备并切换到iOS6上的UICollectionView。我们甚至使用某些运行时技巧在运行时为旧版本的iOS创建UICollectionView。理想情况下,您只需链接文件,一切都可以在旧系统上运行。实际上,它并不那么容易,尤其是当您使用UICollectionView类的子类时,因为它们无法在运行时替换。

#3


2  

There's no compatibility solution for pre-6.0 deployment via storyboards, but PSTCollectionView does support iOS 5.0+ and is actively maintained. It does work at runtime to use UICollectionView* on 6.0 and later, and should be storyboard compatible.

没有通过故事板进行6.0之前部署的兼容性解决方案,但PSTCollectionView确实支持iOS 5.0+并且得到了积极维护。它在运行时可以在6.0及更高版本上使用UICollectionView *,并且应该与storyboard兼容。