-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
widthForComponent not setting desired width #19
Comments
Hi @serjooo! If I understood your setup correctly, you have 2 components in your menu. The width for components is calculated left-to-right. If you provide the same value for all components and the total view width is greater than the sum of all components' widths, then the last (right-most) component will take the rest of the space, ignoring the specified number. To work around this issue, you can specify the exact width for the desired component and set automatic width for the others: - (CGFloat)dropdownMenu:(MKDropdownMenu *)dropdownMenu widthForComponent:(NSInteger)component {
if (self.view.frame.size.width > 375) {
[dropdownMenu setUseFullScreenWidth:NO];
return component == 1 ? 100.0 : 0.0;
} else {
[dropdownMenu setUseFullScreenWidth:YES];
return 0;
}
} Also, you can take a look at the following delegate method: /// Return NO if the component is used as a dummy space for other components
/// and should not be interacted with. The disclosure indicator is hidden
/// for such components. Default = YES.
- (BOOL)dropdownMenu:(MKDropdownMenu *)dropdownMenu enableComponent:(NSInteger)component; In case you need some specific layout for your menu, you can add some empty components. Hope this helps 🙂 |
Hello, Sorry I'm late for replying, got really busy and had found a different workaround for this. However, the setup you thought I have is wrong. I have One component and this component I was attempting at giving it different widths according to screen size. However, no matter the size I return, the width of the component was staying at the default size set in the class. |
@serjooo I tried to reproduce your issue with one component, but it all worked as expected. The device screen size also didn't matter. |
I can confirm this bug. I set the width as below, and in iPhone SE it takes over the whole width. The funny thing is in iPhone 6, it the margins work. But in iPhone SE, it is full width no matter what value I set this to.
|
I am attempting to set a custom width for devices > 375 technically ipads to take a specific amount of width but not matter the width I return the drop down menu's width stays at I guess the default size. In addition, I have set the setUseFullScreenWidth to NO on viewDidLoad, if that makes any difference. This is the code I am using and a screenshot of the simulator on ipadAir2 is attached as well
The text was updated successfully, but these errors were encountered: