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
Doh004
Apr 22, 2007

Mmmmm Donuts...
Double post, but I think I figured something out but I'm not sure if this is correct:

1. Subclass the AFHTTPRequestOperationManager and implement the +(instanceType)manager (so I can set my BaseURL) and HTTPRequestOperationWithRequest
2. Subclass the AFHTTPRequestOperation and implement initWithRequest (to set my own header properties) as well as (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace and (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:.
- I'm not sure about this one because neither of those two methods are getting called so I'm a bit confused.

I'm able to successfully hit my environment (webservices) that has a valid AuthenticationChallenge, but not my local development environment so something isn't 100% right. Am I at least on the right track?

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

pokeyman posted:

I'm trying to generate tests at runtime and get Xcode to actually say "Tests failed" when the tests fail.

Suffix the name of your generated test classes with "Tests" and you're golden. It even shows up in the Test Navigator, complete with runtime-generated test methods, and successes/failures appear (once you expand the test class).

Xcode's slow as poo poo while running the tests the first time as it adds everything to the navigator but then it's all good.

Oh, and if anyone treads this way after me: you'll want at least one method prefixed with "test" compiled into your test class so you can selectively enable/disable your tests by looking at the various user defaults set by XCTest. (Ugh.)

edit: Also, I guess don't override -name in your test case class if you want anything to appear in the test navigator?

edit2: Xcode sure doesn't like 8,000 unit tests. Guess it's time to shove 'em all into one method.

Doh004 posted:

Double post, but I think I figured something out but I'm not sure if this is correct:

1. Subclass the AFHTTPRequestOperationManager and implement the +(instanceType)manager (so I can set my BaseURL) and HTTPRequestOperationWithRequest
2. Subclass the AFHTTPRequestOperation and implement initWithRequest (to set my own header properties) as well as (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace and (void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:.
- I'm not sure about this one because neither of those two methods are getting called so I'm a bit confused.

I'm able to successfully hit my environment (webservices) that has a valid AuthenticationChallenge, but not my local development environment so something isn't 100% right. Am I at least on the right track?

I think the canonical method to override for setting headers is -HTTPRequestOperationWithRequest:success:failure:, fiddling with the request before calling up to super. Also look into -[AFHTTPRequestSerializer setValue:forHTTPHeaderField:] if you don't need such fine-grained control. No need to subclass AFHTTPRequestOperation just for this.

No idea about authentication challenges unfortunately. Though I notice that AFURLConnectionOperation implements some NSURLConnection delegate methods. Maybe their implementations are tripping up the methods you expect to see called in your subclass?

pokeyman fucked around with this message at 10:00 on Nov 20, 2013

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Also some seriously cool DTrace stuff and some more cool DTrace stuff for poking around in apps. Mostly other apps, but might be useful for your own apps too!

Doh004
Apr 22, 2007

Mmmmm Donuts...

pokeyman posted:

I think the canonical method to override for setting headers is -HTTPRequestOperationWithRequest:success:failure:, fiddling with the request before calling up to super. Also look into -[AFHTTPRequestSerializer setValue:forHTTPHeaderField:] if you don't need such fine-grained control. No need to subclass AFHTTPRequestOperation just for this.

No idea about authentication challenges unfortunately. Though I notice that AFURLConnectionOperation implements some NSURLConnection delegate methods. Maybe their implementations are tripping up the methods you expect to see called in your subclass?

To start off thank you for your help and congratulations on deciphering my poorly worded post(s)!

The reason I subclassed the whole RequestOperation was to give me access to those authentication methods - which aren't getting called.

But I think you were right! I also found (BOOL)allowInvalidCertificates which exists on the AFSecurityPolicy in the AFHTTPRequestOperationManager which when set to YES allows me to hit my local environments (but is set to NO for test/production). Now I don't even need to overwrite any of the RequestOperation methods and can keep this cleaner.

Now, as to why it's not saving any of the cookies normally... that's a whole nother problem I need to figure out.

Hughlander
May 11, 2005

Doc Block posted:

Also, your getters/setters are nonstandard. It would be better to use properties and follow the naming conventions, so you'd have something like
Objective-C code:
// DataModel.h

@interface DataModel : NSObject

// We're using copy because if somebody passes in a subclass of NSString (such as
// NSMutableString) we don't want the underlying string data changed without our knowledge,
// so for NSString properties it's a good idea to use copy. This doesn't waste memory since
// on plain old immutable NSString's -copy just calls -retain; only on NSMutableString
// will this result in an actual unique copy of the object and its data. Note that you
// only get this special behavior on Foundation classes.

@property (nonatomic, copy) NSString *currentRoom;
@property (nonatomic, copy) NSString *previousRoom;
@property (nonatomic, copy) NSString *language;

While this applies to the vast minority of people here (I may be the only one?) I just want to point out that a lot of these are good iOS/OSX/Cocoa suggestions but not necessarily the best Objective-C ones. For instance I have GNUStep being called from a JNI callback. What does that mean? Well no NSRunLoop so dispatch_async is out. Furthermore let's see what GNUStep's NSString has to say:

Objective-C code:
- (id) copyWithZone: (NSZone*)zone
{
  /*
   * Default implementation should not simply retain ... the string may
   * have been initialised with freeWhenDone==NO and not own its
   * characters ... so the code which created it may destroy the memory
   * when it has finished with the original string ... leaving the
   * copy with pointers to invalid data.  So, we always copy in full.
   */
  return [[NSStringClass allocWithZone: zone] initWithString: self];
}
Oh. :effort: Of course this is probably going to lead me to swizzle the implementation to one that does just call [retain] and gently caress off NoCopy/freeWhenDone for performance reasons.

Doctor w-rw-rw-
Jun 24, 2008

Hughlander posted:

While this applies to the vast minority of people here (I may be the only one?) I just want to point out that a lot of these are good iOS/OSX/Cocoa suggestions but not necessarily the best Objective-C ones.
Population it's not good advice for: you, who knows why you're the exception, or people who are doing something crazy enough that they are way out in left field
Population it's good advice for: everyone else

GNUStep is a joke, anyway. So is Cocotron. What are you using them for?

Hughlander
May 11, 2005

Doctor w-rw-rw- posted:

Population it's not good advice for: you, who knows why you're the exception, or people who are doing something crazy enough that they are way out in left field
Population it's good advice for: everyone else

GNUStep is a joke, anyway. So is Cocotron. What are you using them for?

We talked about it at WWDC..

Doctor w-rw-rw-
Jun 24, 2008

Hughlander posted:

We talked about it at WWDC..
The last several months have been absolutely, totally nuts such that I can't remember what happened five weeks ago, let alone five months. Really sorry about that.

EDIT:question deleted because I misremembered the function I was asking about

Doctor w-rw-rw- fucked around with this message at 10:39 on Nov 21, 2013

Funso Banjo
Dec 22, 2003

How do you delete an item from Connect? I have an app I was working on, have an entry for it in Connect's "Manage Your Apps" in "Prepare for Upload" status, but am no longer going to release said app.

It's bugging me, cluttering up my already pretty hectic "Manage Your Apps" screen, but have never had to delete one before in this way. And I am unable to work out how to remove it. I am sure it's really simple and I am being an idiot . . . what the hell do I click?

ultramiraculous
Nov 12, 2003

"No..."
Grimey Drawer

Funso Banjo posted:

How do you delete an item from Connect? I have an app I was working on, have an entry for it in Connect's "Manage Your Apps" in "Prepare for Upload" status, but am no longer going to release said app.

It's bugging me, cluttering up my already pretty hectic "Manage Your Apps" screen, but have never had to delete one before in this way. And I am unable to work out how to remove it. I am sure it's really simple and I am being an idiot . . . what the hell do I click?

You have to remove it from sale by unchecking all the territories in Rights and Pricing, and then when its status changes to "Developer Removed from Sale" or whatever, then a "Delete App" button will show up.

PoopShipDestroyer
Jan 13, 2006

I think he's ready for a chair
Does anyone know if using the NSNetService property "includesPeerToPeer" allows Bonjour communication across devices with wifi turned on but not connected to any specific networks? I set the property to YES, but even though my devices can find other services, they don't properly resolve the net service when told to connect. Everything works fine across wifi networks and bluetooth, so I feel like I'm missing something obvious.

DreadCthulhu
Sep 17, 2008

What the fuck is up, Denny's?!
How do you correctly render math notation / formulas in iOS? I'm thinking that popping open a UIWebView and having it render some MathML would be one way, but I'm wondering if there are alternatives. Actually I guess one could implement this server-side and have the app request PNG images from the server. Interesting.

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

RiggenBlaque posted:

Does anyone know if using the NSNetService property "includesPeerToPeer" allows Bonjour communication across devices with wifi turned on but not connected to any specific networks? I set the property to YES, but even though my devices can find other services, they don't properly resolve the net service when told to connect. Everything works fine across wifi networks and bluetooth, so I feel like I'm missing something obvious.

Shows how much I know, I thought you had to use the new Multipeer connection framework which has the MCSession stuff to initiate a connection (IIRC it will use Bluetooth or WiFi peer unless both devices are on the same infrastructure WiFi).

I don't think this area well sussed out yet, the docs don't even cover the includesPeerToPeer property.

PoopShipDestroyer
Jan 13, 2006

I think he's ready for a chair

Ender.uNF posted:

Shows how much I know, I thought you had to use the new Multipeer connection framework which has the MCSession stuff to initiate a connection (IIRC it will use Bluetooth or WiFi peer unless both devices are on the same infrastructure WiFi).

I don't think this area well sussed out yet, the docs don't even cover the includesPeerToPeer property.

Yeah, I have a pretty tenuous grasp on the whole thing myself, but my understanding is that the foundation networking stuff handles finding other devices for you, but leaves the actual communication up to you. I think the multipeer stuff handles not only finding devices, but makes sending data a lot easier. Of course, that's not super useful if you already have the entire architecture built already.

It's pretty frustrating that some of these NSNetService features were briefly mentioned at WWDC almost 6 months ago and we still have absolutely no documentation on it.

DreadCthulhu
Sep 17, 2008

What the fuck is up, Denny's?!
Those of you who use Crashlytics, what's the deal with the dozens and dozens of crashes in all sorts of random places, often Apple basic libraries, once your app is in enough hands? I'm trying to figure out if we're just not implementing poo poo right, or if a lot of this is the app dying either when it's killed by the OS for lack of memory, or when the device is rebooted etc.

Doctor w-rw-rw-
Jun 24, 2008

DreadCthulhu posted:

Those of you who use Crashlytics, what's the deal with the dozens and dozens of crashes in all sorts of random places, often Apple basic libraries, once your app is in enough hands? I'm trying to figure out if we're just not implementing poo poo right, or if a lot of this is the app dying either when it's killed by the OS for lack of memory, or when the device is rebooted etc.
Devices? OS version? iOS had an address space bug on 64-bit that resulted in 1GB of available address space instead of 2GB. And since it was 64-but, it had to map both 32 an 64 bit versions of system libraries, so OOM was a real bad problem briefly. That was fixed, but check your logs. What kinds of devices and OSes are reporting the crashes and where, specifically?

DreadCthulhu
Sep 17, 2008

What the fuck is up, Denny's?!
What are my options in iOS as far as rendering text and small images inline? Should I not bother trying to do this in UIKit and just slap some HTML in a UIWebView? This is pretty much 100% solved in a browser.

Doctor w-rw-rw-
Jun 24, 2008

DreadCthulhu posted:

What are my options in iOS as far as rendering text and small images inline? Should I not bother trying to do this in UIKit and just slap some HTML in a UIWebView? This is pretty much 100% solved in a browser.

TextKit, or if you need to support pre-iOS7, Core Text: http://stackoverflow.com/questions/3899178/how-to-draw-images-among-rich-text-with-coretext-ios

That said, pre-iOS7 is going to be more of a pain as far as text and inline small images go.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
UIWebView is certainly going to be the lowest-effort solution if it's not interactive in any way, but it adds its own set of issues to deal with and the performance overhead is not trivial.

Bartie
Mar 20, 2006

You must defeat Sheng Long to stand a chance.
I should start by saying that I'm new and not very good with Xcode yet. I'm trying to add a regular switch (or label or anything, really) to a toolbar, but anything I drop onto it ends up behind it. The blue thing at the bottom is a regular Switch and the viewController is currently classless.

I've added this toolbar by drag-and-dropping it onto the view, as the navigationController's toolbar simply doesn't show up at all when I run the app. If I try to add anything to that toolbar, it ends up stretched across the entire view. I'm totally clueless as to why that it happening as well.



Any help would be really, really appreciated!

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Bartie posted:

If I try to add anything to that toolbar, it ends up stretched across the entire view. I'm totally clueless as to why that it happening as well.

Try adding a flexible space item to both sides of your toolbar.

I can't really help with the other stuff in your post, sorry. Been away from interface builder for awhile :)

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

Bartie posted:

I should start by saying that I'm new and not very good with Xcode yet. I'm trying to add a regular switch (or label or anything, really) to a toolbar, but anything I drop onto it ends up behind it. The blue thing at the bottom is a regular Switch and the viewController is currently classless.

I've added this toolbar by drag-and-dropping it onto the view, as the navigationController's toolbar simply doesn't show up at all when I run the app. If I try to add anything to that toolbar, it ends up stretched across the entire view. I'm totally clueless as to why that it happening as well.



Any help would be really, really appreciated!

Apple is trying to keep you from shooting yourself in the foot (which can be really helpful and really annoying at times). The navigation bar wants bar button items, though it allows you to place a custom content view. The toolbar also wants bar button items.

If you want to do fancy non-standard things like put switches inside toolbars, you'll need to embed them in a UIBarButtonItem of type Custom. I can't recall if the Interface Builder allows that because I always do stuff like that in code since it's a bit of a fiddly customization. Just init the bar item with initWithCustomView:

A lot of the UIKit controls work that way, for example UITableViewCell. If you don't want to use the standard layouts, it will let you do custom stuff by adding your own custom view(s) as subviews of the contentView, but at that point you are on your own. Want two images on a table cell? Congrats, you signed up to also manage the labels yourself. (And trust me, don't think you can be clever and mess with the view hierarchy to inject stuff into one of the standard layouts. You'll find random stuff like animations not working, sizing not playing correctly, etc)


Edit: to be clear, you should not put a switch on a toolbar. Use a bar button with the selected and normal states as a toggle.

Doc Block
Apr 15, 2003
Fun Shoe
I don't know about Xcode 5, but in Xcode 4 if you tried to drag a non-UIBarButtonItem object (let's say a UISwitch) onto a toolbar it would do all that for you: create a UIBarButtonItem with a custom view, with the custom view being your UISwitch.

Bartie
Mar 20, 2006

You must defeat Sheng Long to stand a chance.

pokeyman posted:

Try adding a flexible space item to both sides of your toolbar.

I can't really help with the other stuff in your post, sorry. Been away from interface builder for awhile :)

I tried but no luck, thanks though! :)

Ender.uNF posted:

Apple is trying to keep you from shooting yourself in the foot (which can be really helpful and really annoying at times). The navigation bar wants bar button items, though it allows you to place a custom content view. The toolbar also wants bar button items.

If you want to do fancy non-standard things like put switches inside toolbars, you'll need to embed them in a UIBarButtonItem of type Custom. I can't recall if the Interface Builder allows that because I always do stuff like that in code since it's a bit of a fiddly customization. Just init the bar item with initWithCustomView:

A lot of the UIKit controls work that way, for example UITableViewCell. If you don't want to use the standard layouts, it will let you do custom stuff by adding your own custom view(s) as subviews of the contentView, but at that point you are on your own. Want two images on a table cell? Congrats, you signed up to also manage the labels yourself. (And trust me, don't think you can be clever and mess with the view hierarchy to inject stuff into one of the standard layouts. You'll find random stuff like animations not working, sizing not playing correctly, etc)


Edit: to be clear, you should not put a switch on a toolbar. Use a bar button with the selected and normal states as a toggle.

Thanks a lot for the great explanation! I didn't realize that toolbars only accepted "dedicated" items. A switch just seemed like the go-to item for toggling, but a button should be fine! I'll save the custom stuff for later.

Doc Block posted:

I don't know about Xcode 5, but in Xcode 4 if you tried to drag a non-UIBarButtonItem object (let's say a UISwitch) onto a toolbar it would do all that for you: create a UIBarButtonItem with a custom view, with the custom view being your UISwitch.

Yeah, that would have been nice. I tried creating a new project from scratch and still had the same issue. It might just be me missing something.

unixbeard
Dec 29, 2004

I'm working on something using core audio, and whenever I start the graph i get a bunch of messages like this

pre:
warning: Could not find object file "/tmp/build-tmp-1/proj/mac/xcode/build/BassStation.build/Release/BassStation.build/Objects-normal/i386/AUBase.o" - no debug information available for "/tmp/build-tmp-1/proj/mac/xcode/../../au-sdk-10.4/AUPublic/AUBase/AUBase.cpp".

warning: Could not find object file "/tmp/build-tmp-1/proj/mac/xcode/build/BassStation.build/Release/BassStation.build/Objects-normal/i386/AUDispatch.o" - no debug information available for "/tmp/build-tmp-1/proj/mac/xcode/../../au-sdk-10.4/AUPublic/AUBase/AUDispatch.cpp".
It fills up the console log and basically I would just like to ignore it. It only happens at run time and and does not show up in the Issue Navigator. How can I ignore warnings of this type?

DreadCthulhu
Sep 17, 2008

What the fuck is up, Denny's?!

Thanks for the tip. That stuff looks great actually. I guess eventually they'll just reinvent a browser in native code, oh well. The one thing I should have mentioned is that I really need to support complex math expressions in the text itself. I was originally thinking that maybe I'll mix up TextKit with some .png files I'd generate server-side on the fly off of embedded LaTeX syntax, but then I stumbled upon mathjax and that makes a very compelling case of using a UIWebView. Seems like a lot of iOS apps out there are using this to represent text with mathematical notation in it, so I might have to as well. It doesn't really need interactivity of any kind at this point.

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

unixbeard posted:

I'm working on something using core audio, and whenever I start the graph i get a bunch of messages like this


It fills up the console log and basically I would just like to ignore it. It only happens at run time and and does not show up in the Issue Navigator. How can I ignore warnings of this type?


Everything I know about this seems inapplicable to your situation; typically it happens when debugging and the object files aren't available for the binary. You can strip the link from the binary so the debugger will stop trying to locate them, but I doubt Apple shipped the CoreAudio SDK that way.

If rjmcall is still around he might be able to shed more light on exactly when the debugger demands object files versus dSYM files and why it is acting this way.

unixbeard
Dec 29, 2004

Thanks, it was some audio components that must've been released with debugging symbols. strip -S got most of them, except one that complained about code signing. I don't really need/use that one so moved it out of the way.

Hughlander
May 11, 2005

DreadCthulhu posted:

Those of you who use Crashlytics, what's the deal with the dozens and dozens of crashes in all sorts of random places, often Apple basic libraries, once your app is in enough hands? I'm trying to figure out if we're just not implementing poo poo right, or if a lot of this is the app dying either when it's killed by the OS for lack of memory, or when the device is rebooted etc.

AFAIK you can't get a low memory crash report because your app is killed not crashed and there's no opportunity for the crash reporter to write a log file. If you have the device you can see it in device logs though. There's going to be a really low percent of crashes that come from the fact that consumer hardware is lovely and someone somewhere will have a bad device but it should be statistical noise unless you're looking at every crash across millions of app launches. Usually random Apple basic library crashes are being fed bad data. I love looking at a log that's 100% UIKit call stack and realizing that someone somewhere passed bad animation data and I have nothing to go on.

Do you have any of these truly random crashes to share? One other thing to consider is to pay attention to the crashed thread. It doesn't have to be thread 0.

Funso Banjo
Dec 22, 2003

ultramiraculous posted:

You have to remove it from sale by unchecking all the territories in Rights and Pricing, and then when its status changes to "Developer Removed from Sale" or whatever, then a "Delete App" button will show up.

I know this is a week or two ago, but I still can't delete the app.

What you mentioned appears to work for released apps. But this one was never finished, never mind released. It's not really a problem, I suppose, but it's frustrating me that I can't tidy it up.

lord funk
Feb 16, 2004

Funso Banjo posted:

I know this is a week or two ago, but I still can't delete the app.

What you mentioned appears to work for released apps. But this one was never finished, never mind released. It's not really a problem, I suppose, but it's frustrating me that I can't tidy it up.

Have you contacted iTunes Connect support? This is exactly the kind of thing you could request from them.

Froist
Jun 6, 2004

Funso Banjo posted:

I know this is a week or two ago, but I still can't delete the app.

What you mentioned appears to work for released apps. But this one was never finished, never mind released. It's not really a problem, I suppose, but it's frustrating me that I can't tidy it up.

I know it's not really a solution, but Apple will delete it if you don't publish an app within 6 months of registering it on Connect.

Doh004
Apr 22, 2007

Mmmmm Donuts...
Spent the past two days banging my head against getting CocoaPods working correctly along with KIF and automated unit tests in our CI machine - everything finally clicked about an hour ago and things are pretty smooth sailing (famous last words).

:feelsgood:

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.

Doh004 posted:

Spent the past two days banging my head against getting CocoaPods working correctly along with KIF and automated unit tests in our CI machine - everything finally clicked about an hour ago and things are pretty smooth sailing (famous last words).

:feelsgood:

Maybe it's too soon to ask: was it worth it?

Doh004
Apr 22, 2007

Mmmmm Donuts...

pokeyman posted:

Maybe it's too soon to ask: was it worth it?

Who knows, probably is too soon. We'll see if our QA folks actually write out the tests (I've offered to do this but they seem quite adamant about doing it themselves). I just had to get it all set up for them.

To be fair, I hit a point where I'd finished all my current designs and was waiting on some go aheads. I had already replaced old busted rear end networking code with AFNetworking 2 so I've been doing a fair amount of cleanup the past couple of weeks.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
Can someone shed some light on when and how the TopLayoutGuide and BottomLayoutGuide behaviors in iOS7 come into play "automatically"? I've been banging my head on this off-and-on for a while now.

Here's the scenario:

I have a navigation controller that contains a tab bar controller that itself contains 4 view controllers, 2 of which are table view controllers and 2 of which are collection view controllers.

The behavior I'm seeing is that the first tab properly sets its top content inset to display below the navigation bar and content scrolls properly underneath the translucent nav/status bar. However the subsequent three tabs don't have their content insets set to anything so the top row is cut off by the navigation bar.

In addition all four tabs are not scrolling their bottom content above the tab bar at all. They are rendering behind the translucent tab bar properly but when you scroll to the bottom the last row is cut off by the tab bar.

According to the Apple documentation I'm reading as long as your scroll views are directly contained within a UITabBarController or UINavigationController the top and bottom layout offsets should be getting set automatically but I'm seeing that the top layout is working automatically only for the first tab and the bottom layout isn't working for any of the tabs.

I'm not doing anything custom with the frames/bounds/constraints nor am I screwing with any of the default properties for automaticallyAdjustsScrollViewInsets or anything like that. Everything is set correctly to "automatically" do this but it's not working.

Stack Overflow is completely useless as all their answers are either to turn off the behavior using edgesForExtendedLayout or "use storyboards" which I can't do for this current project. I'm sure I can set these offsets programatically but I really want to understand why the thing that Apple says works automatically isn't working automatically.

edit: after exploring this further even setting the content insets programatically isn't a slamdunk because while it places the table/collection view content properly the scroll indicator still hides underneath the nav bar and tab bar, whereas all the visual elements line up properly when UIKit does it automatically. So I guess the more general question is how are devs typically achieving the iOS7 translucent nav/tab bar effect? It seems baffling to me that this seems so difficult for what is the default look and feel of iOS7. I'm convinced I'm missing something.

Dr Monkeysee fucked around with this message at 22:07 on Dec 4, 2013

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Use scrollIndicatorInsets when manually setting the contentInset. Also whoever hosed up the plurality of "contentInset" and "UIEdgeInsets" should apologize.

Are you using auto-layout?

I think I remember seeing some posts in the dev forums about exactly the issues you describe (namely the topLayoutGuide only working on the initially visible tab), maybe try searching there.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
I am using auto-layout. Unfortunately all the online help shows how to constrain some sub element of a view to the toplayout guide (e.g. a button) but not how to make the entirety of the table/collection view constrain to the top layout. If my understanding of constraints is correct I'd have to tie the child controller's view to the tab bar controller's top layout guide which is pretty hacky.

Quickly googling scrollIndicatorInsets led me to the bottom of this page https://developer.apple.com/library...crollViews.html which is setting both contentInset and scrollIndicatorInsets whereas I was just setting the former so I'll try that. Thanks.

It's completely bonkers this behavior takes so much code to make work, right? I'm not nuts for thinking the nav or tab controllers should just be handling this correctly?

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost
I've got it working, here's the solution for the collection view controllers contained within the tab bar controller:

Objective-C code:
- (void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubViews];

    if (!hasAdjustedInsets) {
        UIEdgeInsets currentInsets = self.collectionView.contentInset;
        UIEdgeInsets adjustedInsets = UIEdgeInsetsMake(self.tabBarController.topLayoutGuide.length,
                                                       currentInsets.left,
                                                       CGRectGetHeight(self.tabBarController.tabBar.frame),
                                                       currentInsets.right);
        self.collectionView.contentInset = adjustedInsets;
        self.collectionView.scrollIndicatorInsets = adjustedInsets;
        hasAdjustedInsets = YES;
    }
}
Doing the same thing for the table view controllers is trivial.

Getting the topLayoutGuide value from the tab bar controller makes sense as it's specified by the containing nav bar controller which is the parent of the tab bar controller. The content view wouldn't know its grandparent's offset but its parent would. The one confusing thing is why I have to use tabBarController.tabBar height instead of self.bottomLayoutGuide.length. self.bottomLayoutGuide.length returns the correct value for the first and second tab but, get this, it returns 0 for all subsequent tabs. Whatever. It works. Thanks for your help.

Dr Monkeysee fucked around with this message at 23:35 on Dec 4, 2013

Adbot
ADBOT LOVES YOU

pokeyman
Nov 26, 2006

That elephant ate my entire platoon.
Glad you got something going. I think your hunch is right, it shouldn't be that hard at all. If you're feeling charitable, file a couple radars: one for the table-in-nav-in-tab not automatically adjusting insets bug and one for the first-two-tabs-only bug. Though I understand if you'd rather not bother!

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