Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Glimm
Jul 27, 2005

Time is only gonna pass you by

Doctor w-rw-rw- posted:

and the officially-distributed Android source (last I checked, and for a long time) doesn't even compile; you need to patch it before you can build it yourself.

This hasn't been the case in the last 2+ years that I've been building Android, I'm not sure what you mean?

Feel free to PM me as we're getting off topic

Glimm fucked around with this message at 01:37 on Jan 3, 2014

Adbot
ADBOT LOVES YOU

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice

Volmarias posted:

To be fair, Play and the rest of the Google apps are mostly used as the incentive for the carriers and manufactures to not poo poo all over the devices and break compatibility. Apple has the luxury of being their own manufacturer and mostly being able to tell carriers to gently caress off, which isn't to be discounted lightly.

This is why the Amazon app store is a little concerning for me; I'm waiting for a carrier to ink a deal with Amazon where the device comes with Amazon's appstore instead of play, it's locked down into a dumb phone with pay subscriptions for things you'd get free (Vz Backup Assistant, Vz Navigator, etc), and a marketing blitz makes it a success.

FYI: Manufacturers must sign an agreement that they will not make a non-Google-approved android device, period. That extends to the actual contract manufacturer too. Amazon actually had a difficult time finding someone to make the Kindle tablets for that reason. Foxconn makes official Google-blessed handsets so they can't make any device with a fork or non-approved device for anyone. Ever.

Open my rear end.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Ender.uNF posted:

FYI: Manufacturers must sign an agreement that they will not make a non-Google-approved android device, period. That extends to the actual contract manufacturer too. Amazon actually had a difficult time finding someone to make the Kindle tablets for that reason. Foxconn makes official Google-blessed handsets so they can't make any device with a fork or non-approved device for anyone. Ever.

Open my rear end.

That's interesting to hear, actually. Do you have a source for that?

Glimm
Jul 27, 2005

Time is only gonna pass you by

Volmarias posted:

That's interesting to hear, actually. Do you have a source for that?

I imagine Ender.uNF is referring to this:
http://www.wired.co.uk/news/archive/2013-10/21/googles-iron-grip-on-android

Search for "Locking-in manufacturers".

Basically if you're part of the Open Handset Alliance you're contractually prohibited from building non-Google approved Android devices.

haveblue
Aug 15, 2005



Toilet Rascal
So where do Kindle Fires come from? Does Amazon just have enough clout/money that they can live outside the OHA and get someone to stick with them over the entire rest of the Android ecosystem?

Kallikrates
Jul 7, 2002
Pro Lurker
Doing some research and I have done all the googling, just checking in here to see if I have missed any offline mapping solutions outside of MapBox or library X that supports (MBTiles). Apple and Google both don't allow direct access to tiles and 3rd party distribution.

Doctor w-rw-rw-
Jun 24, 2008

Kallikrates posted:

Doing some research and I have done all the googling, just checking in here to see if I have missed any offline mapping solutions outside of MapBox or library X that supports (MBTiles). Apple and Google both don't allow direct access to tiles and 3rd party distribution.

No idea, but just to make sure this didn't fall through the cracks: http://wiki.openstreetmap.org/wiki/Offline_Openstreetmap

Glimm
Jul 27, 2005

Time is only gonna pass you by

haveblue posted:

So where do Kindle Fires come from? Does Amazon just have enough clout/money that they can live outside the OHA and get someone to stick with them over the entire rest of the Android ecosystem?

Quanta Computer (http://www.zdnet.com/blog/btl/amazon-tablet-coming-into-focus-quanta-reportedly-lands-orders/48146), and yes. They primarily make laptops though so it isn't like they lost other business.

Kallikrates
Jul 7, 2002
Pro Lurker

Doctor w-rw-rw- posted:

No idea, but just to make sure this didn't fall through the cracks: http://wiki.openstreetmap.org/wiki/Offline_Openstreetmap

MBTiles is just a 'spec' for storing OSM data in sqlite. But thanks, I'll see if any of these links pan out.

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Doctor w-rw-rw- posted:

In other, actual programming news, I'm writing an animation framework that can animate arbitrary Objective-C properties, and am working on getting it a) more performant and b) supporting spring-based animations.

Anyone care to help me out?

Sounds interesting, do you have a github or?

Doctor w-rw-rw-
Jun 24, 2008

Carthag posted:

Sounds interesting, do you have a github or?

It's private on bitbucket because it's embedded in an application which I don't want to open-source. I'll go ahead and extract it.

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

Doctor w-rw-rw- posted:

In other, actual programming news, I'm writing an animation framework that can animate arbitrary Objective-C properties, and am working on getting it a) more performant and b) supporting spring-based animations.

How does it differ from Core Animation?

Doctor w-rw-rw-
Jun 24, 2008

eschaton posted:

How does it differ from Core Animation?

Core Animation's animations only apply to CALayers, and although you add the animations client-side, they are sent to the render server. This means that Core Animation is not extensible beyond its hardcoded limitations. For example, I'm making good progress on writing physics-based animations that don't have an actual duration, and instead are defined in terms of force - the plan is to stop the animation once the epsilon is small enough.

Core Animation also makes animations transactional, so dynamically updating the destination point incurs some overhead.

Lastly, because the framework should eventually allow for arbitrary animations, you could imagine writing wacky interpolators for non-numerical things, for example transitioning words into other words using edit distance, or transforming paths into other paths, if you're up for writing those algorithms.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Glimm posted:

I imagine Ender.uNF is referring to this:
http://www.wired.co.uk/news/archive/2013-10/21/googles-iron-grip-on-android

Search for "Locking-in manufacturers".

Basically if you're part of the Open Handset Alliance you're contractually prohibited from building non-Google approved Android devices.

Thanks. It's an interesting article, but I'm inclined to consider most of it at least somewhat biased. The only thing that was surprising was the OHA agreement to not produce Android-based forks that don't pass CTS, although I suspect that there's a reason for that somewhere that's more in depth than "Google = evil". What is interesting is whether there would be a problem manufacturing devices for Amazon if they did pass CTS and CTD.

For reference, I worked for a certain very well known OEM, working in their lab for a certain very well known US carrier, and the kind of nonsense that was expected and demanded was truly staggering. The carriers told us to break existing functionality so that only their for-pay apps would work, up to and including demanding that we physically block certain Google apps from being installable while breaking functionality for services for everyone but their own subscription apps, and the OEM would continuously try to "innovate" things with the skill of a toddler with Downs syndrome. Not being able to ship with these changes because of potential CTS violations were the only thing that caused any sort of sanity and compatibility to prevail.

Edit: Sorry, this is a little bit ranty and getting off topic. Lets just drop it and move on.

Volmarias fucked around with this message at 01:24 on Jan 4, 2014

Carthag Tuek
Oct 15, 2005

Tider skal komme,
tider skal henrulle,
slægt skal følge slægters gang



Doctor w-rw-rw- posted:

Lastly, because the framework should eventually allow for arbitrary animations, you could imagine writing wacky interpolators for non-numerical things, for example transitioning words into other words using edit distance, or transforming paths into other paths, if you're up for writing those algorithms.

Haha that is literally the first thing that came into my mind as I read the word "arbitrary" - gently caress yeah, let's animate the transition from "on" to "off"

Doctor w-rw-rw-
Jun 24, 2008

Carthag posted:

Haha that is literally the first thing that came into my mind as I read the word "arbitrary" - gently caress yeah, let's animate the transition from "on" to "off"

Okay, I spent the whole day rewriting literally the entire history of the project to something sane. I was going to do this anyhow, but now using it is just a matter of dropping the projects into a workspace and setting up the project build phases properly.

Here it is: https://github.com/toulouse/ATAnimationKit

Caveat: I suck at C++. I don't know much about it yet so I am definitely doing tons of Bad Things™ with it.

A lot of this was written in haste or in the pursuit of getting something working, so it's sloppy work, though I neatened it up a little. If anyone who has ideas on good refactorings can chime in - especially if you know C++ - that would help tons. Also, there's obviously tons of room for performance optimizations (so if anyone sees anything that could be optimized, let me know), my math is most likely wrong and certainly incomplete in places, and it's about to get worse once I write the physics code to use a force calculation to simulate the animation..

Doc Block
Apr 15, 2003
Fun Shoe
What about using a prebuilt 2D physics engine like Chipmunk2D?

Doctor w-rw-rw-
Jun 24, 2008

Doc Block posted:

What about using a prebuilt 2D physics engine like Chipmunk2D?
  • It's timed by a display link (CVDisplayLink on OS X, but should be portable to a CADisplayLink on iOS). Any operation that takes longer than a small amount of time causes frame drops, so overhead is at a premium. This is easily remedied by prodigious use of GCD on a background queue.
  • Seriously? F=ma, v(t + dt) = v(t) + a * dt, and s(t+dt) = s(t) + v(t) * dt are not hard equations to calculate.
  • The important part would have to be implemented anyways, which is the mapping to and from datatypes and automatically updating properties.

a nest of hornets
Nov 17, 2012

by Ralp
I did a thing with nested UICollectionViews/UICollectionViewLayoutAttributes

4,000 cells used in this picture


Here's a short video of it running in the simulator:
http://f.cl.ly/items/1I0w152a2i3N391o1G3M/gridPageFlip1024.mov

I actually managed to get to 25,600 cells on the 5s

It's been described as "a poor man's CAMeshLayer"

a nest of hornets fucked around with this message at 11:03 on Jan 4, 2014

duck monster
Dec 15, 2004

Toady posted:

Microsoft (or MSFT if you're a blogger) was doing things like threatening to revoke Windows licenses from OEMs if they shipped certain alternatives. Apple's policy of not advertising Android hardly prevents Android from reaching customers. Pretty much everyone acknowledges that Apple are assholes, but that's long been common knowledge, and you accept the possibility of getting Sherlocked in exchange for the privilege of developing for a platform whose quality you believe in (:gruber:). Or at least, that's how it used to be before mobile developers migrated from other platforms because iOS makes more money.


As far as I know, companies aren't forbidden from mentioning Android on their websites, but weren't you displaying it in the app itself?

UIWebview pointing to an about page on the website. If you sign up for a newsletter it asks if your interested in Android amongst the other interests you might be interested in.

So I guess so, but by the same token I can point safari at google and violate that same rule using apples own software.

lord funk
Feb 16, 2004

FOLLOW ME BRUH posted:

I did a thing with nested UICollectionViews/UICollectionViewLayoutAttributes

Dude, jesus. Collection views are my kryptonite, so I'm blown away here. I do want to ask why you decided to go with collection views over a traditional mesh, though.


wakachamo posted:

I'm not sure how much of pre-release software we're supposed to talk about over here for obvious reasons but all I'm gonna say is you should really check out if they have any beta software available on the Dev Center.

Just sayin' is all.

I'm running 7.1 beta 2 with Xcode51 DP2, and I don't see any quicklook improvements. Are you referring to something else?

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

lord funk posted:

I'm running 7.1 beta 2 with Xcode51 DP2, and I don't see any quicklook improvements. Are you referring to something else?

If you're still not getting what you want from quicklook, there's the option of implementing debugQuickLookObject now for an object. You can return a UIImage/NSAttributedString/whatever

damaca
Feb 7, 2009
Is there any secret to extracting objects which aren't strings from an NSDictionary? Spent the last two hours trying to figure this one out with no solution:

code:
NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys: storedStringObject, @"stringObject", 
storedNumberObject, @"numberObject", 
storedAudioObject, @"audioObject";
Accessing the string is easy enough:

code:
 NSString *foo = [userInfo ObjectForKey:@"stringObject"];
However, accessing the NSNumber and AVAudioPlayer don't seem to work with comparable code:

code:
 NSNumber *foo = [userInfo ObjectForKey:@"numberObject];
code:
 AVAudioPlayer *foo = [userInfo ObjectForKey:@"audioObject"];
When accessing the NSNumber object, it seems to come back as (null) when doing an NSLog to console.

I've also tried a more complicated version to access the NSNumber, but that also has not worked:

code:
NSNumber *foo = [NSNumber numberWithInt:[[userInfo objectForKey:@"numberObject"] intValue]];

haveblue
Aug 15, 2005



Toilet Rascal
One gotcha with the dictionaryWithObjectsAndKeys method- if any of the objects in the list happen to be null, it will stop processing right there and ignore subsequent valid objects in the list. Then it returns a dictionary with half the keys missing and causes confusing non-obvious lookup failures like that.

That's not happening in the example here, but maybe in your original code?

Glimm
Jul 27, 2005

Time is only gonna pass you by

Just a suggestion, do yourself a favor and use the improved syntax:

code:
NSDictionary *userInfo = @{@"stringObject": storedStringObject, @"numberObject": @42, @"audioObject": storedAudioObject};
NSString *foo = userInfo[@"stringObject"];
If you're going to use the old syntax, you should have sentinel 'nil' at the end of your NSDictionary.

Glimm fucked around with this message at 01:45 on Jan 6, 2014

damaca
Feb 7, 2009
Thanks for the replies.

Glimm posted:

Just a suggestion, do yourself a favor and use the improved syntax:

code:
NSDictionary *userInfo = @{@"stringObject": storedStringObject, @"numberObject": @42, @"audioObject": storedAudioObject};
NSString *foo = userInfo[@"stringObject"];
If you're going to use the old syntax, you should have sentinel 'nil' at the end of your NSDictionary.

That updated syntax is much more preferable to the old system. I should avoid blindly accepting the advice on stackoverflow...

The new syntax also revealed the problem with my code that was not exposed as an error in the original NSDictionary script:

haveblue posted:

One gotcha with the dictionaryWithObjectsAndKeys method- if any of the objects in the list happen to be null, it will stop processing right there and ignore subsequent valid objects in the list. Then it returns a dictionary with half the keys missing and causes confusing non-obvious lookup failures like that.

That's not happening in the example here, but maybe in your original code?

In my code, the AVAudioPlayer entry was before the NSNumber entry. Since I had not set up the AVAudioPlayer before this point, that caused the processing to stop and meant the NSNumber entry was also not processed. Thanks again for the advice!

lord funk
Feb 16, 2004

Worth noting that you can store an [NSNull null] object if you want to store a NULL object in a dictionary.

damaca posted:

That updated syntax is much more preferable to the old system. I should avoid blindly accepting the advice on stackoverflow...
My two rules for StackOverflow:

1. Always check the date of the posts.
2. You may have found the answer to your question, but your question may be entirely wrong.

a nest of hornets
Nov 17, 2012

by Ralp

lord funk posted:

Dude, jesus. Collection views are my kryptonite, so I'm blown away here. I do want to ask why you decided to go with collection views over a traditional mesh, though.

CAMeshLayer is private :saddowns:

I arrived at this point because I was originally interested in what a UICollectionView would look like with screen sized cells and various layer effects. I had a really pathetic flipping effect working, but found myself wishing that I had even a few more CALayers to play with (I was willing to settle for a 4x4 grid at this point).

So I wrote a function for UICollectionViewCell that drew the cell's layer to an image and broke the resulting UIImage up into a grid of UImages, and then used a grid of cells with UIImageViews inside of a child collectionView (the parent being the full page cell). Interaction is disabled on the child (lol), and the parent passes it's contentOffset along as it updates. That contentOffset is what drives the values of the transforms in each gridCell's UICollectionViewLayoutAttributes.

This worked okay enough for 4x4, but it was already pretty slow, and I wanted more cells. The project was a hard coded mess at this point, but I was excited about it, so I sent the project over to this iOS animation wizard dude I know to see what he thought.

He hit me back with some great suggestions, the first being that: Instead of drawing the cell's layer manually, I should use [cell drawViewHierarchyInRect:afterScreenUpdates:], which was added in iOS7 and is ~15x faster. Also, by saving the screenshot as a CGImageRef instead of a UIImage, and setting the layer.contents of each gridCell to (id)screenshotCGImageRef, we reduce the number of backing stores, which cut memory use by ~20% and made everything much faster.

Through further profiling, I found out that the bottlenecks were in my layoutAttributesForElementsInRect methods. I pulled as much as I could out of the loops, swapped them out with concurrent block enumeration, and enabled drawsAsynchronously on the cell's layers. This gave me another decent speed up, but it still just wasn't fast enough. Profiling still showed that layoutAttributesForElementsInRect was the biggest and most common offender. I wasn't sure where to go from here, so I spent the rest of yesterday cleaning the project up and throwing it in a private repo.

I realized today, while I was making dinner (I'm not sure what triggered this), that I was calling [super layoutAttributesForElementsInRect]. You have to do this, or your subclass won't work. What I didn't realize is that, because I'm already enumerating over every UICollectionViewLayoutAttribute, instead of passing rect along with the call to super, I can just use CGRectZero instead!

Now what you see in the original video, 1024 cells, actually runs on the 5 or 5s without pegging 100% CPU the entire time! I had a quite choppy 9-19FPS yesterday, but now it's a much more consistent 35-45FPS.

Next step is to set up cell masking with NSSet's of indexPaths and use arrays of attributes per mask, instead of just enumerating over all of them with a bunch of if statements tossed about like a scrub. If this works as well as I think it should, not only will it be easier to write effects for, but it could be fast enough to make 25,600 cells more than just a slide show on a 5s!!

All that said, I still haven't really spent any work on the actual animation or effects yet… Once I get all of the rotations set correctly and add in shadows/highlights, this is gonna be pretty nuts.

Edit: here's a short video w/ some fade

What's the best way to record the actual iPhone screen? It's much smoother on the device

lord funk posted:

I'm running 7.1 beta 2 with Xcode51 DP2, and I don't see any quicklook improvements. Are you referring to something else?

Maybe this? https://github.com/ryanolsonk/LLDB-QuickLook

a nest of hornets fucked around with this message at 10:33 on Jan 6, 2014

Simulated
Sep 28, 2001
Lowtax giveth, and Lowtax taketh away.
College Slice
Methinks an upcoming Xcode feature hath been spotted:

quote:

Clang now includes a new tool clang-format which can be used to automatically format C, C++ and Objective-C source code. clang-format automatically chooses linebreaks and indentation and can be easily integrated into editors, IDEs and version control systems. It supports several pre-defined styles as well as precise style control using a multitude of formatting options. clang-format itself is just a thin wrapper around a library which can also be used directly from code refactoring and code translation tools.

Please tell me this means Xcode will soon fix my intendation when I surround existing code with an if statement.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
That was developed by Google, and to the best of my knowledge none of the other Google-developed clang tools have made it into Xcode. Would be nice to have, though.

Glimm
Jul 27, 2005

Time is only gonna pass you by

Ender.uNF posted:

Methinks an upcoming Xcode feature hath been spotted:


Please tell me this means Xcode will soon fix my intendation when I surround existing code with an if statement.

Please happen. Uncrustify is kind of a pain to setup/use.

Kallikrates
Jul 7, 2002
Pro Lurker
I've been using uncrustify for a couple weeks now; no complaints. I use a slightly modified default config I found somewhere which is maybe an 85% solution. But that last 15 seems to not be worth it for something I can more or less fire and forget.

Doc Block
Apr 15, 2003
Fun Shoe

Plorkyeran posted:

That was developed by Google, and to the best of my knowledge none of the other Google-developed clang tools have made it into Xcode. Would be nice to have, though.

Wonder if Google will fork LLVM like they did with WebKit. "We're forking because, umm, reasons! Apple was being a really big meanie!" :rolleyes:

lord funk
Feb 16, 2004


I'm impressed. I recently tricked a CollectionView into loading all its images at once at load (thereby defeating the purpose of using a collection view entirely) just to get it to scroll smoothly. What you're doing is wizardry to me.

I see some cool Quicklook things, and making your own is great, I was just commenting on the hit / or MISS MISS MISS results on Apple's own objects.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed

Doc Block posted:

Wonder if Google will fork LLVM like they did with WebKit. "We're forking because, umm, reasons! Apple was being a really big meanie!" :rolleyes:
I'm not aware of any real friction between Google and Apple on LLVM, which is quite different from how WebKit was.

Doctor w-rw-rw-
Jun 24, 2008

lord funk posted:

I'm impressed. I recently tricked a CollectionView into loading all its images at once at load (thereby defeating the purpose of using a collection view entirely) just to get it to scroll smoothly. What you're doing is wizardry to me.

I see some cool Quicklook things, and making your own is great, I was just commenting on the hit / or MISS MISS MISS results on Apple's own objects.

Why not load and decode the images on a background thread? Image loading is threadsafe.

Hughlander
May 11, 2005

Ender.uNF posted:

Methinks an upcoming Xcode feature hath been spotted:


Please tell me this means Xcode will soon fix my intendation when I surround existing code with an if statement.

Doesn't support Allman Style (Aka: Awesome Style) out of the box so I'm sad.

lord funk
Feb 16, 2004

Doctor w-rw-rw- posted:

Why not load and decode the images on a background thread? Image loading is threadsafe.

Is this what you mean?

Objective-C code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TCColorSetCell"
                                                                           forIndexPath:indexPath];    
    TCColorSetCell * tcCell = (TCColorSetCell *)cell;

    dispatch_async(dqueue, ^{
        dispatch_async(dispatch_get_main_queue(), ^{
            tcCell.colorSetImageView.image = self.colorSetImages[indexPath.row];
        });
    });
    
    return cell;
}
It does make scrolling smooth, but if I run [self.collectionView reloadData] while scrolled midway through, all the images just scramble up.

Doctor w-rw-rw-
Jun 24, 2008

lord funk posted:

Is this what you mean?

Objective-C code:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"TCColorSetCell"
                                                                           forIndexPath:indexPath];    
    TCColorSetCell * tcCell = (TCColorSetCell *)cell;

    dispatch_async(dqueue, ^{
        dispatch_async(dispatch_get_main_queue(), ^{
            tcCell.colorSetImageView.image = self.colorSetImages[indexPath.row];
        });
    });
    
    return cell;
}
It does make scrolling smooth, but if I run [self.collectionView reloadData] while scrolled midway through, all the images just scramble up.
That's setting the image asynchronously from a cache (not a bad idea), but that isn't changing the thread image decoding is happening on. Dispatching to a private background queue to decode the image then dispatching to main sounds like a good idea to me, but also keep in mind that row-indexing and threading can get really complex really, really fast and can produce some pretty hairy situations. If the index of something changes, you could be setting the wrong image.

I implemented something a great deal more involved than that, but I'm probably NDA'd for a little while longer from talking about it, or at least I want to make sure that talking technical details doesn't reveal anything further until the NDA is cleared. Hopefully it won't be too long; ping me later.

Also, FYI, reloadData is a nuclear option of last resort when adding/removing items from a table/collection.

Adbot
ADBOT LOVES YOU

lord funk
Feb 16, 2004

Doctor w-rw-rw- posted:

keep in mind that row-indexing and threading can get really complex really, really fast and can produce some pretty hairy situations. If the index of something changes, you could be setting the wrong image.

I just ran into this in another situation, and I don't understand how a collection view decides what its cells indexes are.

Let's say we have a collection view with 7 items. I scroll passed 4 of them, so only the last 3 are visible. Then I segue to a different view controller entirely and return. At -viewDidAppear, I run the following and get this output:

code:
    for (int i=0; i<[self.collectionView numberOfItemsInSection:0]; i++) {
        UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:[NSIndexPath indexPathForItem:i inSection:0]];
        NSLog(@"cell at indexPath %@",[self.collectionView indexPathForCell:cell]);
    }
code:
cell at indexPath (null) is (null)
cell at indexPath (null) is (null)
cell at indexPath (null) is (null)
cell at indexPath (null) is (null)
cell at indexPath <NSIndexPath: 0x1781aaa0> {length = 2, path = 0 - 7}
cell at indexPath <NSIndexPath: 0x1a059840> {length = 2, path = 0 - 8}
cell at indexPath <NSIndexPath: 0x1a055b10> {length = 2, path = 0 - 9}
So, the first 4 were dropped and the collection view only has 3 live cells. But when I select the last cell, you would think its index would be (0 - 9), but it actually returns:
code:
select cell:<NSIndexPath: 0x1a06abc0> {length = 2, path = 0 - 2}
0 - 2? What am I not understanding? Why would it return an indexPath that represents its visual index? I have no idea how to handle that returned value, or what I missing about where it gets its indexPath.

lord funk fucked around with this message at 18:51 on Jan 8, 2014

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply