UICollectionView provides a more flexible way to display data compared to UITableView. It handles grids, horizontal scrolling, and custom layouts. The API is similar to UITableView with data sources, delegates, and cell/view reuse. UICollectionViewFlowLayout provides an easy way to create basic grids that can be customized. Fully custom layouts require subclassing UICollectionViewLayout to position cells and views.
Awesome html with ujs, jQuery and coffeescriptAmir Barylko
The document provides an overview of HTML5, jQuery, and CoffeeScript. It discusses semantic HTML tags, unobtrusive JavaScript, jQuery features like DOM manipulation and events, and CoffeeScript features like string interpolation, functions, objects, and classes. Contact information is also included at the end.
Ruby on Rails is an open-source web application framework that uses the Model-View-Controller pattern. It uses Ruby as its programming language. Rails provides conventions for building database-backed web applications, including generating scaffolding for basic CRUD operations. The document demonstrates how to generate a Rails application, scaffold a Bookmarks model, add validations and associations to Categories, and integrate Ajax functionality. Rails emphasizes conventions over configuration for directory structure and default actions.
This document outlines an iOS programming 101 course aimed at beginners and intermediate developers. The one-day course will teach attendees how to build a basic iOS app with a list view and detail view using common UI controls like tables, navigation controllers and images. It will cover app structure, views, view controllers, data handling and adapting apps for both iPhone and iPad. The course uses demonstrations and hands-on exercises to help attendees create their own app from scratch by the end.
This document discusses the state of the Search API module in Drupal 8. It provides an overview of Search API, Search API Solr, Facets, and related modules. It describes the architecture of Search API in Drupal 8, including the search index, server, and display components. It also demonstrates Search API and Facets functionality and discusses open issues, like improving documentation, tests, and the administration UI.
The document provides tips for Rails developers when working with designers, suggesting they use consistent naming for models and views, integrate CSS stylesheets and images properly, and use techniques like conditional comments and body classes to target styles for different browsers like Internet Explorer.
This document discusses blocks and Grand Central Dispatch in iOS. It provides definitions and examples of blocks, including their syntax, key features like capturing variables, and common usage scenarios in Apple's SDKs. It also defines Grand Central Dispatch as a set of APIs for simplifying concurrent programming. GCD uses dispatch queues to schedule blocks or tasks for execution. There are serial queues that execute one task at a time and concurrent queues for concurrent execution. The document provides examples of creating and using different types of dispatch queues.
The 8th Dnepropetrovsk iOS Practice Leaders Community Meet-up, which took place on Thursday, February 5th, was dedicated to collection view layouts.
Anatoliy Tukhtarov, iOS developer with 2+ years of experience made a presentation about:
— what UICollectionViewLayout is;
— when to create your own layout;
— creating your own layout from scratch;
— self-sizing collection view items;
— adding gestures to collection view (drag and drop, pinch to zoom, autoscroll, etc.)
During the presentation we created waterfall layout step by step and discuss appearing issues.
The presentation will be interesting for all developers who want to expand their knowledge about UICollectionView.
https://yadi.sk/d/eeEdMTiueTW9s — keynote
https://yadi.sk/i/DVDq3O3leTW8n — pdf
https://yadi.sk/i/t6-nw3uMeTW7D — pptx
Awesome html with ujs, jQuery and coffeescriptAmir Barylko
The document provides an overview of HTML5, jQuery, and CoffeeScript. It discusses semantic HTML tags, unobtrusive JavaScript, jQuery features like DOM manipulation and events, and CoffeeScript features like string interpolation, functions, objects, and classes. Contact information is also included at the end.
Ruby on Rails is an open-source web application framework that uses the Model-View-Controller pattern. It uses Ruby as its programming language. Rails provides conventions for building database-backed web applications, including generating scaffolding for basic CRUD operations. The document demonstrates how to generate a Rails application, scaffold a Bookmarks model, add validations and associations to Categories, and integrate Ajax functionality. Rails emphasizes conventions over configuration for directory structure and default actions.
This document outlines an iOS programming 101 course aimed at beginners and intermediate developers. The one-day course will teach attendees how to build a basic iOS app with a list view and detail view using common UI controls like tables, navigation controllers and images. It will cover app structure, views, view controllers, data handling and adapting apps for both iPhone and iPad. The course uses demonstrations and hands-on exercises to help attendees create their own app from scratch by the end.
This document discusses the state of the Search API module in Drupal 8. It provides an overview of Search API, Search API Solr, Facets, and related modules. It describes the architecture of Search API in Drupal 8, including the search index, server, and display components. It also demonstrates Search API and Facets functionality and discusses open issues, like improving documentation, tests, and the administration UI.
The document provides tips for Rails developers when working with designers, suggesting they use consistent naming for models and views, integrate CSS stylesheets and images properly, and use techniques like conditional comments and body classes to target styles for different browsers like Internet Explorer.
This document discusses blocks and Grand Central Dispatch in iOS. It provides definitions and examples of blocks, including their syntax, key features like capturing variables, and common usage scenarios in Apple's SDKs. It also defines Grand Central Dispatch as a set of APIs for simplifying concurrent programming. GCD uses dispatch queues to schedule blocks or tasks for execution. There are serial queues that execute one task at a time and concurrent queues for concurrent execution. The document provides examples of creating and using different types of dispatch queues.
The 8th Dnepropetrovsk iOS Practice Leaders Community Meet-up, which took place on Thursday, February 5th, was dedicated to collection view layouts.
Anatoliy Tukhtarov, iOS developer with 2+ years of experience made a presentation about:
— what UICollectionViewLayout is;
— when to create your own layout;
— creating your own layout from scratch;
— self-sizing collection view items;
— adding gestures to collection view (drag and drop, pinch to zoom, autoscroll, etc.)
During the presentation we created waterfall layout step by step and discuss appearing issues.
The presentation will be interesting for all developers who want to expand their knowledge about UICollectionView.
https://yadi.sk/d/eeEdMTiueTW9s — keynote
https://yadi.sk/i/DVDq3O3leTW8n — pdf
https://yadi.sk/i/t6-nw3uMeTW7D — pptx
Building your first iOS app using XamarinGill Cleeren
Your task before coming to this session: know C# and .NET. Your mission during this session: learn how you can leverage your C# knowledge to build iOS apps. If you decide to accept this mission: be prepared to see how in just 60 minutes, a complete iOS app will appear in front of you. All using C#. This session will destroy itself after 60 minutes.
Hi performance table views with QuartzCore and CoreTextMugunth Kumar
This document provides an introduction to using QuartzCore and CoreText to build high-performance table views on iOS. It begins by explaining why fast scrolling is important for the iPhone experience. It then outlines three different methods for compositing table view cells (subviews, direct drawing, hybrid) and their pros and cons. The document dives into using QuartzCore and CoreText to render text and images within table view cells, providing examples of using CALayers, CATextLayers, and NSAttributedStrings. It concludes with performance tips for working with these frameworks like using dispatch_once.
The document discusses iOS self-sizing cells and techniques for implementing self-sizing in table views and collection views. It covers using estimated sizes, laying out cells with constraints, and calculating accurate sizes. The AppDevKit library is presented as a solution for streamlining self-sizing cells, with methods that lay out cells, calculate sizes, and cache reusable cells.
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreSuzanne Dergacheva
As a Drupal themer or site builder, layouts are one of the first considerations when implementing the design of a Drupal site. In this session, we'll talk about different techniques for creating layouts in Drupal 8. From how to configure landing page content using Paragraphs or Panels to implementing a grid system with your theme, you'll walk away with some new tips and tricks under your belt.
Specifically, we'll cover:
Configuring Drupal components to use in your layouts
How Drupal 8 blocks change our approach to building layouts
Creating a design framework for your layouts
Designing successful landing pages layouts
Theming your layouts: sing grid systems or CSS from scratch
This session is aimed at site builders and themers who are familiar with Drupal site building and are looking for new techniques for creating layouts and landing pages.
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon DublinSuzanne Dergacheva
This presentation from DrupalCon Dublin covered site building techniques for creating landing pages and layouts, including using custom blocks, paragraphs, and panels, and then different theming approaches for creating these layouts.
The document discusses ListViews in Android, including introducing AdapterViews and common adapter types like ArrayAdapter. It covers implementing a basic ListView with an ArrayAdapter, using custom adapters, view holders for optimization, adding listeners, headers/footers, and using ListActivity for simplified list handling.
This document discusses replacing the use of $GLOBALS['TYPO3_DB'] with Doctrine DBAL for database queries in TYPO3 extensions. Doctrine DBAL provides a database abstraction layer that supports multiple database vendors, whereas $GLOBALS['TYPO3_DB'] only supports MySQL. Migrating to Doctrine DBAL offers benefits like a more reliable industry standard and easier API. The document provides examples of common queries like select, insert, update using the Doctrine query builder and highlights best practices for security and restrictions. $GLOBALS['TYPO3_DB'] will be removed in TYPO3 8 LTS, so extensions need to migrate to Doctrine DB
Developing a Tabview in iOS app using Swift as a programming language. Swift is now getting adopted by developer community. Have a look on our presentation ..
Client-side MVC with Backbone.js (reloaded)iloveigloo
The document discusses a presentation on client-side MVC with Backbone.js. It includes an agenda that covers why Backbone.js, its architecture including models, collections, views, templates and routers, real world examples, tips and tricks, and extras. The architecture section describes how Backbone.js provides structure using models, collections, views and connecting to RESTful APIs. It also outlines the MVC components and their roles.
The document discusses client-side MVC with Backbone.js. It begins with an overview of Backbone.js and why it provides a useful structure for web applications. It then covers the main aspects of the Backbone architecture including models, collections, views, templates, and routers. Examples are provided for each component and how they work together. Real-world applications using Backbone, including for invoicing and social media analytics, are briefly described.
Alexander Blom
Isle of Code
Overview
Some people consider responsive design to be cross-platform, and responsive design to be resizing for containers. However, this misses the distinction of fluid design & often leads to slow and bad programmatic implementations. This talk will cover the distinction and provide pointers on how to implement responsive apps that are also performant.
Attendees should understand a differing view on how to build cross-platform apps, and the difference between fluid & responsive design.
Target Audience
Programmers, designers & cssers who think a single page with lots of media queries is a good idea.
Five Things Audience Members Will Learn
What is fluid design?
The difference between responsive & fluid design
Why are responsive designs often slow?
How to implement responsive designs that are performant
Bonus points to be revealed in talk!
This document summarizes new features in iOS development, including new Objective-C language features like NSNumber literals and boxed expressions, the use of storyboards to define view controller transitions and relationships, customizing UI elements globally with UIAppearance, and useful techniques like implementing singletons and using Grand Central Dispatch. It provides examples and demonstrations of these topics.
The document provides an agenda for an iOS programming course. It discusses prerequisites like having a Mac and an Apple developer account. It then covers key iOS concepts like MVC design pattern, views, view controllers. It defines what views and view controllers are in iOS and common UI elements like labels, buttons, text fields. It also discusses how to create and add views programmatically and with Interface Builder.
iPhone Camp Birmingham (Bham) - Intro To iPhone Developmentandriajensen
This document provides an introduction to iPhone development. It outlines that iPhone development is worthwhile due to the large audience of over 35 million devices. It encourages starting coding by learning Objective-C, Model-View-Controller patterns, and Apple's development tools. Resources for learning include Apple's documentation, online tutorials, and books. Coding practice and asking questions are also recommended for learning iPhone development.
Masterin Large Scale Java Script ApplicationsFabian Jakobs
Writing large desktop-like web applications is a challenge. Adapting such an application to different markets, languages or brands is even more of a challenge. This talk shows how the open source JavaScript framework qooxdoo can be leveraged to build such a rich internet application. As a real-life example the free web mail client gmx.com is used. This talk discusses the development model, customization and deployment of such an application.
Learn how JavaScript applications of this size and complexity are fundamentally different from classic web applications, and what issues come up when building fast, multi-language, multi-brand JavaScript applications.
Session 14 - Working with table view and search barVu Tran Lam
The document provides an overview of table views and search bars in iOS application development. It discusses introducing table views, customizing their appearance, navigating data hierarchies with table views, and manipulating table views by inserting and deleting rows and sections. It also covers introducing search bars, customizing their appearance, and working with search bars in table views by creating search bar scopes and displaying search results in the table view. The document includes code examples and recommends additional Apple documentation references for table views and search bars.
1. Content is defined mathematically using point coordinates that are independent of physical screen pixels.
2. During rendering, point coordinates are multiplied by a scale factor and rasterized into pixels at a higher resolution than the device screen.
3. The rendered image is then downsampled to match the pixel resolution of the physical screen before being displayed.
Hyperloop will make Titanium more native then ever, but also more standard JavaScript at the same time. As an example, the API will now be fully prototypal, and because it’s all (Hyperloop) JavaScript you can extend every bit of it without touching Objective-C or JAVA.
More Related Content
Similar to Introducing collection views - Mark Pospesel
Building your first iOS app using XamarinGill Cleeren
Your task before coming to this session: know C# and .NET. Your mission during this session: learn how you can leverage your C# knowledge to build iOS apps. If you decide to accept this mission: be prepared to see how in just 60 minutes, a complete iOS app will appear in front of you. All using C#. This session will destroy itself after 60 minutes.
Hi performance table views with QuartzCore and CoreTextMugunth Kumar
This document provides an introduction to using QuartzCore and CoreText to build high-performance table views on iOS. It begins by explaining why fast scrolling is important for the iPhone experience. It then outlines three different methods for compositing table view cells (subviews, direct drawing, hybrid) and their pros and cons. The document dives into using QuartzCore and CoreText to render text and images within table view cells, providing examples of using CALayers, CATextLayers, and NSAttributedStrings. It concludes with performance tips for working with these frameworks like using dispatch_once.
The document discusses iOS self-sizing cells and techniques for implementing self-sizing in table views and collection views. It covers using estimated sizes, laying out cells with constraints, and calculating accurate sizes. The AppDevKit library is presented as a solution for streamlining self-sizing cells, with methods that lay out cells, calculate sizes, and cache reusable cells.
Creating Landing Pages and Layouts for Drupal 8 - DrupalCon BaltimoreSuzanne Dergacheva
As a Drupal themer or site builder, layouts are one of the first considerations when implementing the design of a Drupal site. In this session, we'll talk about different techniques for creating layouts in Drupal 8. From how to configure landing page content using Paragraphs or Panels to implementing a grid system with your theme, you'll walk away with some new tips and tricks under your belt.
Specifically, we'll cover:
Configuring Drupal components to use in your layouts
How Drupal 8 blocks change our approach to building layouts
Creating a design framework for your layouts
Designing successful landing pages layouts
Theming your layouts: sing grid systems or CSS from scratch
This session is aimed at site builders and themers who are familiar with Drupal site building and are looking for new techniques for creating layouts and landing pages.
Creating Layouts and Landing Pages for Drupal 8 - DrupalCon DublinSuzanne Dergacheva
This presentation from DrupalCon Dublin covered site building techniques for creating landing pages and layouts, including using custom blocks, paragraphs, and panels, and then different theming approaches for creating these layouts.
The document discusses ListViews in Android, including introducing AdapterViews and common adapter types like ArrayAdapter. It covers implementing a basic ListView with an ArrayAdapter, using custom adapters, view holders for optimization, adding listeners, headers/footers, and using ListActivity for simplified list handling.
This document discusses replacing the use of $GLOBALS['TYPO3_DB'] with Doctrine DBAL for database queries in TYPO3 extensions. Doctrine DBAL provides a database abstraction layer that supports multiple database vendors, whereas $GLOBALS['TYPO3_DB'] only supports MySQL. Migrating to Doctrine DBAL offers benefits like a more reliable industry standard and easier API. The document provides examples of common queries like select, insert, update using the Doctrine query builder and highlights best practices for security and restrictions. $GLOBALS['TYPO3_DB'] will be removed in TYPO3 8 LTS, so extensions need to migrate to Doctrine DB
Developing a Tabview in iOS app using Swift as a programming language. Swift is now getting adopted by developer community. Have a look on our presentation ..
Client-side MVC with Backbone.js (reloaded)iloveigloo
The document discusses a presentation on client-side MVC with Backbone.js. It includes an agenda that covers why Backbone.js, its architecture including models, collections, views, templates and routers, real world examples, tips and tricks, and extras. The architecture section describes how Backbone.js provides structure using models, collections, views and connecting to RESTful APIs. It also outlines the MVC components and their roles.
The document discusses client-side MVC with Backbone.js. It begins with an overview of Backbone.js and why it provides a useful structure for web applications. It then covers the main aspects of the Backbone architecture including models, collections, views, templates, and routers. Examples are provided for each component and how they work together. Real-world applications using Backbone, including for invoicing and social media analytics, are briefly described.
Alexander Blom
Isle of Code
Overview
Some people consider responsive design to be cross-platform, and responsive design to be resizing for containers. However, this misses the distinction of fluid design & often leads to slow and bad programmatic implementations. This talk will cover the distinction and provide pointers on how to implement responsive apps that are also performant.
Attendees should understand a differing view on how to build cross-platform apps, and the difference between fluid & responsive design.
Target Audience
Programmers, designers & cssers who think a single page with lots of media queries is a good idea.
Five Things Audience Members Will Learn
What is fluid design?
The difference between responsive & fluid design
Why are responsive designs often slow?
How to implement responsive designs that are performant
Bonus points to be revealed in talk!
This document summarizes new features in iOS development, including new Objective-C language features like NSNumber literals and boxed expressions, the use of storyboards to define view controller transitions and relationships, customizing UI elements globally with UIAppearance, and useful techniques like implementing singletons and using Grand Central Dispatch. It provides examples and demonstrations of these topics.
The document provides an agenda for an iOS programming course. It discusses prerequisites like having a Mac and an Apple developer account. It then covers key iOS concepts like MVC design pattern, views, view controllers. It defines what views and view controllers are in iOS and common UI elements like labels, buttons, text fields. It also discusses how to create and add views programmatically and with Interface Builder.
iPhone Camp Birmingham (Bham) - Intro To iPhone Developmentandriajensen
This document provides an introduction to iPhone development. It outlines that iPhone development is worthwhile due to the large audience of over 35 million devices. It encourages starting coding by learning Objective-C, Model-View-Controller patterns, and Apple's development tools. Resources for learning include Apple's documentation, online tutorials, and books. Coding practice and asking questions are also recommended for learning iPhone development.
Masterin Large Scale Java Script ApplicationsFabian Jakobs
Writing large desktop-like web applications is a challenge. Adapting such an application to different markets, languages or brands is even more of a challenge. This talk shows how the open source JavaScript framework qooxdoo can be leveraged to build such a rich internet application. As a real-life example the free web mail client gmx.com is used. This talk discusses the development model, customization and deployment of such an application.
Learn how JavaScript applications of this size and complexity are fundamentally different from classic web applications, and what issues come up when building fast, multi-language, multi-brand JavaScript applications.
Session 14 - Working with table view and search barVu Tran Lam
The document provides an overview of table views and search bars in iOS application development. It discusses introducing table views, customizing their appearance, navigating data hierarchies with table views, and manipulating table views by inserting and deleting rows and sections. It also covers introducing search bars, customizing their appearance, and working with search bars in table views by creating search bar scopes and displaying search results in the table view. The document includes code examples and recommends additional Apple documentation references for table views and search bars.
1. Content is defined mathematically using point coordinates that are independent of physical screen pixels.
2. During rendering, point coordinates are multiplied by a scale factor and rasterized into pixels at a higher resolution than the device screen.
3. The rendered image is then downsampled to match the pixel resolution of the physical screen before being displayed.
Hyperloop will make Titanium more native then ever, but also more standard JavaScript at the same time. As an example, the API will now be fully prototypal, and because it’s all (Hyperloop) JavaScript you can extend every bit of it without touching Objective-C or JAVA.
This document contains release notes for multiple versions of Xcode. The main sections summarize new features, known issues, resolved issues and deprecations for each Xcode release. Xcode 6 introduced major new features like support for the Swift programming language, improved testing and debugging tools, and enhancements to Interface Builder, asset catalogs and localization.
Get step-by-step instructions on implementing notifications in your apps.Jigar Maheshwari
This document provides an overview and best practices for using local and push notifications on iOS and Mac OS X. It discusses the differences between local and push notifications, when each should be used, how to implement them in apps, and considerations for the user experience and backend server implementation. The document includes code samples for registering for and handling notifications as well as creating and scheduling local notifications.
The document discusses Auto Layout in iOS, including:
- UIView properties related to Auto Layout like constraints and intrinsicContentSize
- Creating constraints programmatically and with the Visual Format Language (VFL)
- Debugging and resolving issues with constraints
- Animating views and properties like constraints over time
- Integrating Auto Layout with view controller lifecycles and orientation changes
The document provides guidelines for designing iOS apps, including:
1. Deferring to content and using negative space, full-screen elements, and translucent UI to elevate the user's content.
2. Providing clarity through simplicity, color, legible typography, and borderless buttons.
3. Using depth, layers, and transitions between screens to communicate hierarchy and relationships between on-screen objects.
The document provides an overview of views in UIKit, which are the building blocks for constructing user interfaces in iOS apps. It discusses the purpose and implementation of views, how to configure views through Interface Builder and programmatically, and covers the content, behavior, and appearance of views. Specific view types like buttons, labels, images views and more complex views like table views and scroll views are also mentioned.
iOS 7 introduces many UI changes, such as borderless buttons, translucent bars, and full-screen layout for view controllers. Using Xcode 5, you can build a project for iOS 7 and run it in iOS 7 Simulator to get a first glimpse of the way the app looks with iOS 7 UI.
1. Introducing Collection Views
Mark Pospesel
Mobile Architect
Y Media Labs
code github.com/mpospese/IntroducingCollectionViews
slides bit.ly/ViTNiK
@mpospese
Slides and code on
flash drives
2. Who Am I?
• Studied mathematics, marine biology, and teaching English as a Second
Language
• 14 years industry experience
• Programming for mobile since 1999!
• Mobile Architect for Y Media Labs
7. Grid views and horizontal scrollers
The hard way
• UIScrollView
• manually place “cells”
• DataSource delegate
• delegate for selection, appearance, disappearance, etc.
• create views for cells on demand and cache cells for reuse
8. What if you wanted something even more complex?
9. Enter UICollectionView
• Handles grids
• Handles horizontal line scrollers
• Handles pretty much any custom layout you can imagine
• High-performance even with large data sets
• Works well with Core Data and NSFetchedResultsController
• Familiar delegate / data source API pattern
18. UICollectionView
• If you know how to use UITableView, you mostly know how to use simple
Collection Views already
19. UICollectionViewDataSource
• number of sections
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
• number of items in each section
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:
(NSInteger)section
• configure cells
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
• configure supplementary views
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView
viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
20. Cell and view reuse
• Cells, supplementary views, and decoration views are all reused
• Each type of view needs to be registered for reuse (nib or class)
registerClass:forCellWithReuseIdentifier:
registerNib:forCellWithReuseIdentifier:
registerClass:forSupplementaryViewOfKind:withReuseIdentifier:
registerNib:forSupplementaryViewOfKind:withReuseIdentifier:
21. Cell and view reuse
• Cells, supplementary views, and decoration views are all reused
• Each type of view needs to be registered for reuse (nib or class)
• dequeue will instantiate the class if necessary
dequeueReusableCellWithReuseIdentifier:forIndexPath:
dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath:
22. UICollectionViewDelegate
• Manages selecting and highlighting
• should/did select/deselect
• should/did highlight/unhighlight
• Tracks the removal of cells
• didEndDisplay cell/supplementary view
• Manages actions for cells
• should show menu
• canPerform/perform action on cell
25. UICollectionViewFlowLayout
• Subclass of UICollectionViewLayout for grids
• Makes it super easy to implement basic grids
• Supports headers and footers
• Can be customized via properties or by delegate
• property = global
• delegate = per item or section
• Can be subclassed
49. UICollectionViewLayoutAttributes
• Describe position, size, visual state of collection items
• Apply to cells, supplementary views, and decoration views
• Set by layout
• Used by collection view to configure cells and views
• Subclass to add additional attributes
51. When to subclass UICollectionViewFlowLayout
• add decoration views
• add extra supplementary views (beyond headers and footers)
• adjust the default layout attributes of items
• add new layout attributes
• use custom insert or delete animations
52. When to subclass UICollectionViewLayout
• The layout you want is nothing like a grid
• You’d have to change the default attributes so much that it would be less
work to not derive from flow layout
53. How UICollectionViewLayout works
• prepareLayout
• collectionViewContentSize
• layoutAttributesForElementsInRect:
• provide layout attributes on demand
layoutAttributesForItemAtIndexPath:
layoutAttributesForSupplementaryViewOfKind:atIndexPath:
layoutAttributesForDecorationViewOfKind:atIndexPath:
• invalidateLayout
54. Invalidating layouts
• explicit: invalidateLayout
• implicit: performBatchUpdates:completion:
• implicit: override shouldInvalidateLayoutForBoundsChange:
• called when contentOffset changes or when bounds change
• always return YES
• return YES only if bounds change
- (BOOL)shouldInvalidateLayoutForBoundsChange:(CGRect)oldBounds
55. Miscellaneous Tips
• don’t use collectionView.frame / bounds outside of prepareLayout
• consider setting hidden = YES instead of alpha = 0
59. How to add decoration views
• Create your own layout class
• Register your decoration view
registerNib:forDecorationViewOfKind:
registerClass:forDecorationViewOfKind:
• Return attributes for all decoration views
layoutAttributesForElementsInRect:
layoutAttributesForDecorationViewOfKind:atIndexPath:
60. When to subclass UICollectionViewLayoutAttributes
• You need additional attributes beyond those found in the base class
61. How to create custom attributes
• Subclass UICollectionViewLayoutAttributes
• add additional properties
• Important! You must implement copyWithZone:
- (id)copyWithZone:(NSZone *)zone
{
CustomAttributes *attributes = [super copyWithZone:zone];
attributes.customProperty = self.customProperty;
return attributes;
}
62. How to create custom attributes
• Subclass UICollectionViewLayoutAttributes
• Subclass UICollectionViewLayout (or flow layout)
• implement layoutAttributesClass to return your custom class
+ (Class)layoutAttributesClass
{
return [CustomAttributes class];
}
63. How to create custom attributes
• Subclass UICollectionViewLayoutAttributes
• Subclass UICollectionViewLayout (or flow layout)
• implement layoutAttributesClass to return your custom class
• set your custom attributes
layoutAttributesForElementsInRect:
layoutAttributesForItemAtIndexPath:
layoutAttributesForSupplementaryViewOfKind:atIndexPath:
layoutAttributesForDecorationViewOfKind:atIndexPath:
64. How to create custom attributes
• Subclass UICollectionViewLayoutAttributes
• Subclass UICollectionViewLayout (or flow layout)
• In your cell, supplementary view, or decoration view classes implement
applyLayoutAttributes:
- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
if ([layoutAttributes isKindOfClass:[CustomAttributes class]])
{
CustomAttributes *customAttributes = (CustomAttributes *)layoutAttributes;
// Do something interesting with them
}
}
69. • override finalLayoutAttributesForDisappearingItemAtIndexPath:
• gets called for every item that needs to be moved too, so need to track
index of deleted item(s).
• do that in prepareForCollectionViewUpdates: (don’t forget to call super!)
Customizing delete animations
What they didn’t tell you
- (void)prepareForCollectionViewUpdates:(NSArray *)updateItems
{
[super prepareForCollectionViewUpdates:updateItems];
self.deleteIndexPaths = [NSMutableArray array];
for (UICollectionViewUpdateItem *update in updateItems)
{
if (update.updateAction == UICollectionUpdateActionDelete)
{
[self.deleteIndexPaths addObject:update.indexPathBeforeUpdate];
}
}
}
70. • override finalLayoutAttributesForDisappearingItemAtIndexPath:
• gets called for every item that needs to be moved too, so need to track
index of deleted item(s).
• do that in prepareForCollectionViewUpdates: (don’t forget to call super!)
• clean up in finalizeCollectionViewUpdates
Customizing delete animations
What they didn’t tell you
- (void)finalizeCollectionViewUpdates
{
[super finalizeCollectionViewUpdates];
self.deleteIndexPaths = nil;
}
71. • override finalLayoutAttributesForDisappearingItemAtIndexPath:
Customizing delete animations
What they didn’t tell you
- (UICollectionViewLayoutAttributes *)finalLayoutAttributesForDisappearingItemAtIndexPath:
(NSIndexPath *)itemIndexPath
{
if ([self.deleteIndexPaths containsObject:itemIndexPath])
{
UICollectionViewLayoutAttributes* attributes = [self
layoutAttributesForItemAtIndexPath:itemIndexPath];
// Configure attributes ...
return attributes;
}
return nil;
}
72. • same applies to initialLayoutAttributesForAppearingItemAtIndexPath:
• will get called for both insert and delete animations
• must call super
Customizing delete animations
But wait, there’s more!
- (UICollectionViewLayoutAttributes *)initialLayoutAttributesForAppearingItemAtIndexPath:
(NSIndexPath *)itemIndexPath
{
UICollectionViewLayoutAttributes *attributes = [super
initialLayoutAttributesForAppearingItemAtIndexPath:itemIndexPath];
if ([self.insertIndexPaths containsObject:itemIndexPath])
{
if (!attributes)
attributes = [self layoutAttributesForItemAtIndexPath:itemIndexPath];
// Configure attributes ...
}
return attributes;
}
75. Summary
• Collection views are very powerful, flexible tool
• UICollectionViewFlowLayout is highly customizable via properties,
subclassing, or delegation
• UICollectionView can support any arbitrary layout
• If you can dream it, build a layout for it!
76. Support for iOS 4.3 & 5
PSTCollectionView
• GitHub project by Peter Steinberger
• uses UICollectionView classes under iOS 6
• uses custom classes under iOS 4.3 and 5
• doesn’t have all the animations (yet)
• github.com/steipete/PSTCollectionView