Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 7    Views: 91

fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
02/12/14 01:23 AM (11 years ago)

Menu Image Advanced: how to set the gap between header image and menu items?

Hi there! As some CP settings are not yet implemented for this plugin, I have to tweak some code here and there. I've found where to set the size and corners of the buttons, but I can't find where to fine-tune the List Header Height, i.e. the gap between header image and first menu item. Anybody knows where to scratch for it? Thanks in advance for any help! Cheers Jack
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/12/14 02:04 AM (11 years ago)
The advanced menu with image shares code with menu with image. If you want to look into ways of modifying the header image height, have a look here - http://www.buzztouch.com/plugins/discussions.php?pid=F018606BDA6027B90A3ED49
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/12/14 03:33 AM (11 years ago)
Thanks, but these discussions are quite old (mostly pre-BT3.0) and anyway my issue is not about header image height, it's about the space between the header image and the first menu item. In the 'old' BTv1.5 age, we were able to fine-tune the height of this space in the List Header Height and List Footer Height settings. In the BT3.0 Advanced Menu self-hosted CP, the List Header Height setting doesn't have any effect anymore and I can't find where to modify the height of this space in the code. This predefined gap is ok on iPad, but on iPhone it's too big. Strangely, this issue appears only if I set the List Style to 'Rounded Corners, with side margins' (and BTW the side margins are inexistent). Of course I can use the 'Square Corners, no margin' option, but in this case there is no gap at all between header image and first menu item, and the only way to create a gap is to set the Row Height to a higher value... but this gap will then appear between the rows of the menu items (an unsatisfactory workaround). As I'm upgrading an BTv1.5 app, I'd like to keep the same menu style but with the Advanced Menu, which is quite elegant. This 'gap' issue is the last obstacle, but I can't find any workaround! Cheers Jack
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/12/14 04:08 AM (11 years ago)
Try this on for size; it should work out I think… In your WB_screen_menuImage.m file, there is no xib; it's all drawn out in code. In the 'upper' section of 'viewDidLoad' you'll see a lot of code regarding the image header. fine, just scroll on down until you reach the neighborhood of line 138 or so… you'll see this line: [self.myTableView setFrame:CGRectMake(0, imageHeight, imageWidth, tableHeight)]; And basically you can psuedo read it as "table size = cgrectmake(Left, Top, Width, Height) So whereas they're using the imageHeight to place the top (meaning, at the image bottom, begin the table) you can just add a few pixels and see how it suits you: [self.myTableView setFrame:CGRectMake(0, imageHeight + 5, imageWidth, tableHeight)]; would give a 5 pixel "gap" between the image, and the start/top of your tableView. Hope this helps! Cheers! -- Smug
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/12/14 05:44 AM (11 years ago)
You're a wizard, Professor Smug, thanks a lot! Your code lesson helped, but not in the way you thought ;-) I learned something today thanks to you... and the issue is now solved! You didn't actually give the good solution, but all the clues to find it... Let me explain you, just in case it could help somebody else... It's not in WB_screen_menuImage.m but in Cr_menu_advanced.m (OK, this was easy). It's not on line 138 or so, it's on line 170 (easy too). But the solution is not here. It will change the height of the 'hole' in which is displayed the subview, and as I have to put a minus value (imageHeight - 10), the 'hole' will be shortened at bottom too, between the menu items and the tab bar. (Still easy, just trial and error...) But then, I looked just below (line 172), saw stories of 'autoresizingMask'... and thought I could try and tweak that stuff... Here we go: myTableView.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin); Just added a numeric value: myTableView.autoresizingMask = (UIViewAutoresizingFlexibleHeight - 20 | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin); And that was it! (Just don't forget to set List Background Color to 'clear') Whoopee! I still hate code, but code is starting to love me... Thanks and cheers Jack
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/12/14 05:44 AM (11 years ago)
My approach would have involved changing the image to introduce the gap you are seeking (in the graphic). Smug's approach looks more elegant. Good luck and let us know how you get on. Cheers, Alan
 
fusionsch
I hate code!
Profile
Posts: 516
Reg: Dec 28, 2010
Montreux Switze...
11,610
like
02/12/14 05:50 AM (11 years ago)
Thanks, Alan! I'm lucky today!
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/12/14 05:55 AM (11 years ago)
Hmm… glad the wrong solution led you to the right solution :) Cheers! -- Smug
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.