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
lord funk
Feb 16, 2004

Do multiple UITableViews with the same view classes registered for reuse all pull from the same reusable view pool, or do they each create and pull from their own? If the latter, can they be told to pull from the same pool?

edit: seems like they are separate per instance. That sucks.

Adbot
ADBOT LOVES YOU

Doctor w-rw-rw-
Jun 24, 2008

lord funk posted:

Do multiple UITableViews with the same view classes registered for reuse all pull from the same reusable view pool, or do they each create and pull from their own? If the latter, can they be told to pull from the same pool?

edit: seems like they are separate per instance. That sucks.

They pull from the same reuse identifier. If you want to reuse the same cells, you have to make the cells themselves configurable for those different modes. That said, hiding a view takes it out of the render tree, so if you're doing a ton of reuse it might be worth it to amortize the really expensive cost of instantiating and adding the views in each cell for all of its states, and hide/unhide as needed.

That, or aggressively bug the AsyncDisplayKit people to open-source their sliding range stuff (not private info; discussed at NSLondon, publicly streamed), which should be particularly useful for smooth tableview operation.

Manic Mongoose
Aug 5, 2010
I'm trying to get Game Center working on my simple game and I've been going through Ray Wenderlich's tutorial. So far I'm able to have a person login and authenticate, however I'm unsure how to pull up the gameViewController which I assume holds the matchmaking view.

In his tutorial he has a storyboard that navigates from the navigationcontroller -> gameviewcontroller

However for my sprite kit game, I have no storyboard, and it goes defaultViewController -> firstscene.

I have the code that would you call in the navigationcontroller on the defaultViewController that loads first. After logging in Game Center it transitions to the first scene. However I'm unsure where to or how to transition to the gameViewController (which was a class that I had to create) to start the match making.

http://www.raywenderlich.com/60980/game-center-tutorial-how-to-make-a-simple-multiplayer-game-with-sprite-kit-part-1

This is what I'm following.

Any help would be great!

lord funk
Feb 16, 2004

Doctor w-rw-rw- posted:

They pull from the same reuse identifier. If you want to reuse the same cells, you have to make the cells themselves configurable for those different modes. That said, hiding a view takes it out of the render tree, so if you're doing a ton of reuse it might be worth it to amortize the really expensive cost of instantiating and adding the views in each cell for all of its states, and hide/unhide as needed.

That, or aggressively bug the AsyncDisplayKit people to open-source their sliding range stuff (not private info; discussed at NSLondon, publicly streamed), which should be particularly useful for smooth tableview operation.

I thought my problem was the opposite: not a lot of reuse per individual UITableView, but among the pile of them, I figured there could be more sharing. After all that, it turns out what I really needed was to clean out all the UIImageViews and replace them with *much* less invasive UIViews, rasterize like hell, avoid allocating unnecessary views, and switch to programmatic creation of cells instead of nibs.

Buttery scrolling ahoy. :toot:

Doc Block
Apr 15, 2003
Fun Shoe

Manic Mongoose posted:

I'm trying to get Game Center working on my simple game and I've been going through Ray Wenderlich's tutorial. So far I'm able to have a person login and authenticate, however I'm unsure how to pull up the gameViewController which I assume holds the matchmaking view.

In his tutorial he has a storyboard that navigates from the navigationcontroller -> gameviewcontroller

However for my sprite kit game, I have no storyboard, and it goes defaultViewController -> firstscene.

I have the code that would you call in the navigationcontroller on the defaultViewController that loads first. After logging in Game Center it transitions to the first scene. However I'm unsure where to or how to transition to the gameViewController (which was a class that I had to create) to start the match making.

http://www.raywenderlich.com/60980/game-center-tutorial-how-to-make-a-simple-multiplayer-game-with-sprite-kit-part-1

This is what I'm following.

Any help would be great!

You probably need a UINavigationController.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Doctor w-rw-rw- posted:

That, or aggressively bug the AsyncDisplayKit people to open-source their sliding range stuff (not private info; discussed at NSLondon, publicly streamed), which should be particularly useful for smooth tableview operation.

For whoever else cares: http://new.livestream.com/nslondon/anniversary/videos/57840338

I've been eating up this AsyncDisplayKit stuff.

lord funk
Feb 16, 2004

ultramiraculous posted:

For whoever else cares: http://new.livestream.com/nslondon/anniversary/videos/57840338

I've been eating up this AsyncDisplayKit stuff.

This is great. Also I can't wait to switch over to it someday because my podunk attempts at getting off the main thread are pitiful by comparison.

Doc Block
Apr 15, 2003
Fun Shoe
Ugh. I just spent over an hour debugging an AVAudioPlayer "problem". No matter how the audio files were loaded, no matter what audio file I gave it, AVAudioPlayer wouldn't play any sounds. Not on the device, not on the simulator, not even in a little OS X test program. I was getting pretty mad, since AVAudioPlayer is so drat easy and I've used it successfully before.

Then I realized that I wasn't keeping the AVAudioPlayer object anywhere. So it would be created successfully, the call to -play would succeed and it would technically start playback, but then execution got to the end of the method and ARC was helpfully releasing the AVAudioPlayer object, thus stopping sound playback before any sound could be heard. :downsgun:

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
I just spent a couple days on the dumbest loving UICollectionView issue. I have a collection view with a custom layout that displays its contents in a horizontally paged grid. Depending on the number of elements in the whole thing, there might be blank space left over on the last page.

Did you know that if you have a collection view with backgroundColor set to [UIColor clearColor], touching the blank area to start scrolling doesn't work? Only if you touch one of the cells. Likewise, setting a backgroundView with a clear background color causes the same problem.

However, setting the background color to have alpha 0.01 causes scrolling to work again when touching in the empty area.

Wtf, Apple :psyduck:

Doctor w-rw-rw-
Jun 24, 2008

Flobbster posted:

Wtf, Apple :psyduck:

It's not so :psyduck: for a class designed mainly to lay items out in potentially arbitrary positions to pass through touches outside its cells/reusable views by default, if you ask me. Eating touches in empty spaces sounds like it would be a pain in the rear end to get rid of if you needed those touches elsewhere, whereas it's relatively easy to use your aforementioned solutions to eat them.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
I can definitely see how it would be useful in some cases -- especially if someone was using a sparse collection view overlaying other interactive views underneath.

Ease of workaround doesn't excuse the fact that from an API design point-of-view, using background color to control interactivity is a *really* bad code smell, and the workaround being to use an almost-but-not-quite-completely-transparent color is even more jacked up. I'd rather have something like collectionView.forwardsBackgroundTouchesToTheViewsThatYouCanSeeBehindIt = YES.

Echo Video
Jan 17, 2004

Flobbster posted:

I just spent a couple days on the dumbest loving UICollectionView issue. I have a collection view with a custom layout that displays its contents in a horizontally paged grid. Depending on the number of elements in the whole thing, there might be blank space left over on the last page.

Did you know that if you have a collection view with backgroundColor set to [UIColor clearColor], touching the blank area to start scrolling doesn't work? Only if you touch one of the cells. Likewise, setting a backgroundView with a clear background color causes the same problem.

However, setting the background color to have alpha 0.01 causes scrolling to work again when touching in the empty area.

Wtf, Apple :psyduck:

Views with an alpha of 0.0 are removed from the responder chain, I think. Maybe you should use the backgroundView property of the collection view to show whatever it is that is behind the collection view.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Flobbster posted:

I just spent a couple days on the dumbest loving UICollectionView issue. I have a collection view with a custom layout that displays its contents in a horizontally paged grid. Depending on the number of elements in the whole thing, there might be blank space left over on the last page.

Did you know that if you have a collection view with backgroundColor set to [UIColor clearColor], touching the blank area to start scrolling doesn't work? Only if you touch one of the cells. Likewise, setting a backgroundView with a clear background color causes the same problem.

However, setting the background color to have alpha 0.01 causes scrolling to work again when touching in the empty area.

Wtf, Apple :psyduck:

For future reference, I think this is the relevant part of the documentation:

UIView Class Reference: -hitTest:withEvent: posted:


This method ignores view objects that are hidden, that have disabled user interactions, or have an alpha level less than 0.01.

0.01 was a good guess!

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Welp, I didn't realize this was something that applied to all views. Thanks for pointing it out in the doc; I've read hitTest:withEvent: before but I guess I never internalized that part. That's a tidbit I'll never forget now.

It's a custom keyboard extension so I need whatever blurred effect iOS puts underneath to show through, so 0.01 will work well enough -- no background view necessary.

Subjunctive
Sep 12, 2006

✨sparkle and shine✨

I think it's pretty crappy to tie presentation to event processing, as an API choice. It's not hard to have the owner specify that they want the view to be hit-transparent, and way clearer for that to be the case. It's nice that it's documented (though AFAIK not near the places that control alpha-I-mean-alpha-and-event-targeting), but that's sort of a blame-the-user thing. Too much magic.

Doctor w-rw-rw-
Jun 24, 2008

Subjunctive posted:

I think it's pretty crappy to tie presentation to event processing, as an API choice. It's not hard to have the owner specify that they want the view to be hit-transparent, and way clearer for that to be the case. It's nice that it's documented (though AFAIK not near the places that control alpha-I-mean-alpha-and-event-targeting), but that's sort of a blame-the-user thing. Too much magic.

Yeah, I forgot about the alpha-hit-test stuff. It does come in handy, though, when animating things nontrivially from hidden to not hidden or vice versa. I imagine that hits some unhappy corner cases when animating alpha using additive animations - it probably gets tricky to figure out when to call completion blocks and set hidden = YES or NO.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
For what it's worth this is merely the default implementation of hit testing, and there is no problem whatsoever doing with something else in your subclasses of UIView. By all means subclass UICollectionView and return self whenever super returns nil.

It doesn't seem unreasonable on its face to, by default, prevent views from receiving touches when they are utterly imperceptible to the user. I can see why that might be surprising or unwanted behavior, and it is perhaps poorly documented, but it's a defensible decision in my view (lol) and it is easily overridden.

Finally, I couldn't find any indication that views with an alpha of 0 are excluded from the responder chain, but I admit that I did not try very hard, and a simple example project would quickly answer that question. I'll give it a go tomorrow.

pokeyman fucked around with this message at 06:30 on Aug 2, 2014

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doctor w-rw-rw- posted:

Yeah, I forgot about the alpha-hit-test stuff. It does come in handy, though, when animating things nontrivially from hidden to not hidden or vice versa. I imagine that hits some unhappy corner cases when animating alpha using additive animations - it probably gets tricky to figure out when to call completion blocks and set hidden = YES or NO.

Animating views sets their userInteractionEnabled to NO by default, so that isn't really helped by hit testing considering transparency, but of course everything you mention comes into play when keeping interaction enabled during animation.

Doctor w-rw-rw-
Jun 24, 2008

pokeyman posted:

Animating views sets their userInteractionEnabled to NO by default, so that isn't really helped by hit testing considering transparency, but of course everything you mention comes into play when keeping interaction enabled during animation.

Before Facebook's Pop library came out, I was actually using UIViewAnimationOptionAllowUserInteraction quite a bit on some UIs to make them feel responsive, so it's not totally weird.

duck pond
Sep 13, 2007

Flobbster posted:

Thanks, I'll look into that -- it looks like UIFontDescriptorCharacterSetAttribute and matchingFontDescriptors... do what I need.

When I said that I didn't want to iterate over all the fonts in the system, I meant that I was hoping to take advantage of whatever tables the OS might have already built internally, instead of iterating over the fonts myself. I think this will do the trick.

Oh man. You're building the exact same thing as I am (and running into the same problems)

Ninja Rope
Oct 22, 2005

Wee.

Ender.uNF posted:

Are you drawing to the center point of each pixel (x+0.5) or directly on it? My first guess is maybe interpolation artifacts.

Another wild guess, but you could also try drawing to your own backing buffer of fixed resolution then scaling for display to get deterministic behavior. If the display is scaled, are you doing the scaling or is the OS? I wonder if the draw commands are being scaled before drawing (rather than scaling the resulting bitmap). In theory scaling the draw commands would yield better results but I can see that producing some jitter if you're trying to do sub-pixel precise overdraw.

I'm not an expert on this stuff though, so YMMV.

Thanks for the help. I was not drawing the center of the pixel. I decided to try drawing into my own buffer as you suggested and then displaying that to the screen and that seems to fix the problem. I started with:

code:
    nsImage = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:screenWidth
                                        pixelsHigh:screenHeight bitsPerSample:8 samplesPerPixel:4
                                        hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace
                                        bitmapFormat:NSAlphaFirstBitmapFormat bytesPerRow:0
                                        bitsPerPixel:32];
    unsigned char *imageData = [nsImage bitmapData];
And then every frame I'd draw new stuff into imageData and then display it:

code:
    NSRect imageRect = NSMakeRect(0, 0, screenWidth, screenHeight);
    [nsImage drawInRect:imageRect];
This works just fine but only for the first frame of animation, it never draws the rest of the frames. Is there something about re-using an NSBitmapImageRep after calling drawInRect that won't work? Can I not just keep updating the buffer returned by bitmapData and calling drawInRect over and over?

The only way I could get it to work is by malloc'ing a persistent buffer I draw into and then creating a new NSBitmapImageRep every frame (with initWithBitmapDataPlanes:NULL because passing my buffer directly causes a crash) and then memcpy my buffer into the one returned by [nsImage bitmapData] for every frame. I'm sure the format of my data is correct because the memcpy method works, so it must be something with how I'm creating or re-using the NSBitmapImageRep.

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

Ninja Rope posted:

Thanks for the help. I was not drawing the center of the pixel. I decided to try drawing into my own buffer as you suggested and then displaying that to the screen and that seems to fix the problem. I started with:

code:
    nsImage = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:NULL pixelsWide:screenWidth
                                        pixelsHigh:screenHeight bitsPerSample:8 samplesPerPixel:4
                                        hasAlpha:YES isPlanar:NO colorSpaceName:NSCalibratedRGBColorSpace
                                        bitmapFormat:NSAlphaFirstBitmapFormat bytesPerRow:0
                                        bitsPerPixel:32];
    unsigned char *imageData = [nsImage bitmapData];
And then every frame I'd draw new stuff into imageData and then display it:

code:
    NSRect imageRect = NSMakeRect(0, 0, screenWidth, screenHeight);
    [nsImage drawInRect:imageRect];
This works just fine but only for the first frame of animation, it never draws the rest of the frames. Is there something about re-using an NSBitmapImageRep after calling drawInRect that won't work? Can I not just keep updating the buffer returned by bitmapData and calling drawInRect over and over?

The only way I could get it to work is by malloc'ing a persistent buffer I draw into and then creating a new NSBitmapImageRep every frame (with initWithBitmapDataPlanes:NULL because passing my buffer directly causes a crash) and then memcpy my buffer into the one returned by [nsImage bitmapData] for every frame. I'm sure the format of my data is correct because the memcpy method works, so it must be something with how I'm creating or re-using the NSBitmapImageRep.

I would have created it with CGImageCreate or CGBitmapContextCreate which is supposed to support modifying the bitmap data via the pointer from CGBitmapContextGetData. I haven't fooled around with Core Graphics drawing in a little while though so someone who has done it more recently would probably have better advice.

Ninja Rope
Oct 22, 2005

Wee.

Ender.uNF posted:

I would have created it with CGImageCreate or CGBitmapContextCreate which is supposed to support modifying the bitmap data via the pointer from CGBitmapContextGetData. I haven't fooled around with Core Graphics drawing in a little while though so someone who has done it more recently would probably have better advice.

This is working exactly as you described and solves my problem. Thanks!

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice
My math game just got approved, and since I learned most of what I know from reading this thread, here's a bunch of codes:

code:
JTYPJJ4JNE67
7LRAPYYMMFYR
YPLX4T4FMYWA
H73XXFYWJNTH
LXXL7J33AY7P
K3A73NATW3MW
Those are for the "full" version that will have all current and future in-app purchases unlocked.

Doctor w-rw-rw-
Jun 24, 2008

Lumpy posted:

code:

K3A73NATW3MW

Taken. Looks pretty neat! Clean design. The signs' color is a bit too weak, though - trying it out on my iPad in the shade at the train station, the gray is barely perceptible, and the sound is pretty soft, though audible at max volume.

Also, the ready button should glow or slightly scale up and down between 95% and 105% IMO, or whatever looks good, to suggest that it wants to be interacted with and pressed to continue.

Also, any technical details? What libraries did you use to build it? What techniques did you apply / learn / create?

EDIT:
Also, you might want to animate numbers towards the operator they bind more closely to, for order of operations. Example:



EDIT 2: and a reset button as well.

EDIT 3: and a training wheels mode where the intermediate result of two numbers and their operator are shown above.

Doctor w-rw-rw- fucked around with this message at 17:41 on Aug 6, 2014

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Lumpy posted:

code:
LXXL7J33AY7P

Mine!

Fate Accomplice
Nov 30, 2006




I took YPLX4T4FMYWA, thanks very much!

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice


Thanks for the feedback! We are having to rush out a fix for some Game Center stuff (it never showed up in testing, honest!) so I will try and sneak in some changes as well based on your suggestions. I was originally going to have the Ready pulse, but every person we had test (including a bunch of 6 year-olds) immediately tapped on it, so I left that out. Certainly wouldn't hurt to add it though!

As for technology, we used the Pop library for animations, and uh, probably some other stuff :v: . I tried hard to *not* code too much on this one, although I did the UI animations and some other bits and pieces. Lessons learned we many, but mostly from a working relationship perspective with my partner on the app.

Doctor w-rw-rw-
Jun 24, 2008

Lumpy posted:

Thanks for the feedback! We are having to rush out a fix for some Game Center stuff (it never showed up in testing, honest!) so I will try and sneak in some changes as well based on your suggestions. I was originally going to have the Ready pulse, but every person we had test (including a bunch of 6 year-olds) immediately tapped on it, so I left that out. Certainly wouldn't hurt to add it though!
Hmm, good datapoint. Add a 5-second delay before it starts pulsing.

Lumpy posted:

As for technology, we used the Pop library for animations, and uh, probably some other stuff :v: . I tried hard to *not* code too much on this one, although I did the UI animations and some other bits and pieces. Lessons learned we many, but mostly from a working relationship perspective with my partner on the app.
I had a feeling you used pop. :D Overall, very well-done!

Volmarias
Dec 31, 2002

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

Lumpy posted:

7LRAPYYMMFYR

Taken, thanks! I'll take a look!

Edit: In survival mode, you wrote "Harde...". It's "Hard" :shobon:

Also, in survival mode, you don't stop the clock when swapping puzzles, and it takes about as long as the "correct" and swap animations take. Kind of annoying.

Volmarias fucked around with this message at 18:54 on Aug 6, 2014

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Doctor w-rw-rw- posted:

Hmm, good datapoint. Add a 5-second delay before it starts pulsing.

I had a feeling you used pop. :D Overall, very well-done!

:ohdear: I used 4.5


Issues w/ game center is fixed, Ready pulses, and I think I might try my luck at an expedited review.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Lumpy posted:

Issues w/ game center is fixed, Ready pulses, and I think I might try my luck at an expedited review.

Just for game centre fixes? It's not stopping anyone from using the app, is it? Might want to save that for a lovely crash-on-launch bug or something.

wwb
Aug 17, 2004

Is anyone successfully using CI to build / package release iOS apps? It seems that apple makes it loving impossible. If you are please share any good, recent guides on how you get there.

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

wwb posted:

Is anyone successfully using CI to build / package release iOS apps? It seems that apple makes it loving impossible. If you are please share any good, recent guides on how you get there.

I haven't done it myself but here's something for Travis CI. What CI are you using?

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
What problems are you running in to? It isn't particularly difficult other than that all of your options for server hardware are dumb.

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Lumpy posted:

:ohdear: I used 4.5


Issues w/ game center is fixed, Ready pulses, and I think I might try my luck at an expedited review.

Hey, so one bug is you preempt music that's playing on the device. Just starting the app cuts off playback, and your sounds will pause/unpause music. You should be using a different AVAudioSession category like AVAudioSessionCategoryAmbient.

Also seconding reset button somewhere.

wwb
Aug 17, 2004

The build server is TeamCity, the agent is running on a mac mini. Build is executing via ssh using a script. I should note the project is a phone gap app so I'm dealing with a generated xcode project, not something someone can queue up fixes into.

Thanks for the travis CI link -- I can see where we are going wrong in one place -- we tried shipping the keychain rather than loading certificates into a temporary keychain and that is blowing up because apparently apple needs something to approve the use of the key.

The more fundamental issue is that, in the raw, the build dies because there is something about schemes that gets setup when you open a project in xcode. So when I run xcodebuild it just times out after 10 seconds. Now if I open the project it will get to the point where it is dying on code signing which is surmountable.

In either case it is amazing the difference between this and android where it just works if you feed it the right keystore with the right passwords.

Dessert Rose
May 17, 2004

awoken in control of a lucid deep dream...
Speaking of stopping audio when starting, I finally found and fixed my bug with that - it turns out that I was calling prepareForPlayback in the init method of an object that one of my view controllers makes. That was preemptively starting my audio session and stopping everyone else.

I only figured this out by following the apple bug report guidelines of making a small test app and noting that it worked there, then setting break points everywhere to see that hey, what do you know, didFinishLaunchingWithOptions is not even close to the first bit of my code that gets called on startup.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

ultramiraculous posted:

Hey, so one bug is you preempt music that's playing on the device. Just starting the app cuts off playback, and your sounds will pause/unpause music. You should be using a different AVAudioSession category like AVAudioSessionCategoryAmbient.

Also seconding reset button somewhere.

Thanks for the heads up, fixing that now.

What would 'reset' do? Remove the operands, or switch to a new puzzle (in Endless mode)?

Adbot
ADBOT LOVES YOU

Doctor w-rw-rw-
Jun 24, 2008

Lumpy posted:

What would 'reset' do? Remove the operands, or switch to a new puzzle (in Endless mode)?

It would remove the operators, not the operands. You could hide it until there's 2 or more operators (maybe 3), but it's a pain in the butt when you just want to retry placing the operators.

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