- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试制作一个侧边栏菜单,但我遇到了一个小问题。
我解释:
在我的 viewController 类(初始 View Controller )中,在头文件中,我导入了我的类 SideMenuViewController 并且我写道:
-(IBAction)openSideMenu:(id)发件人;
@property(nonatomic, retain) SideMenuViewController *sideMenu;
openSideMenu 操作与菜单按钮关联。
我是这样实现这个方法的:
- (IBAction)openSideMenu:(id)sender {
CGRect destination = self.view.frame;
if(destination.origin.x > 0){
destination.origin.x = 0;
}else{
destination.origin.x += SideMenuX;
}
[UIView animateWithDuration:0.4 animations:^{
self.view.frame = destination;
}completion:^(BOOL finished) {
if(finished){
}
}];
}
SideMenuX 是一个宏:#define SideMenuX 154.4
我的 viewDidLoad 方法如下所示:
- (void)viewDidLoad
{
[super viewDidLoad];
_sideMenu = [[SideMenuViewController alloc] init];
[self.view sendSubviewToBack:_sideMenu.view];
// Do any additional setup after loading the view, typically from a nib.
}
问题是,当我点击菜单按钮时,出现黑屏,而不是侧面菜单 View 。
提前致谢!
最佳答案
两个问题:
self.view.superview
),在您的情况下很可能是 UIWindow:[self.view.superview insertSubview:_sideMenu.view belowSubview:self.view];If you are using a navigation controller, use
self.navigationController.view
instead self.view
. Here is a working example. I created the left view controller inside the storyboard like this:
SideMenuViewController
SideMenuViewController
Instantiate the controller inside viewDidLoad with
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
self.sideMenu = (SideMenuViewController*)[storyboard instantiateViewControllerWithIdentifier:@"SideMenuViewController"];
然后将其作为父 View 的子项插入。
(回答下面的评论)
这一行是问题所在:
[self.view.superview addSubview:_sideMenu.view];
在基于 NIB 的项目中,superview 是 UIWindow,但在 Storyboard 项目中,UIViewController 的 self.view.superview 是 nil。你可以解决这个问题,例如,添加一个 UINavigationViewController。请按照以下步骤操作:
然后将您的代码更改为
_sideMenu = [[SideMenuViewController alloc] initWithNibName:@"SideMenuViewController" bundle:nil];
[self.navigationController.view.superview insertSubview:_sideMenu.view belowSubview:self.navigationController.view];
要隐藏 UINavigationController 的导航栏,请在 Storyboard 中选择它并在 Attributes Inspector 中单击 Hidden (alt+cmd+4)。
关于objective-c - SideMenu 黑色 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13136055/
我正在使用 this library使用 Swift 4 在 iOS 中创建侧边菜单。 但是,这仅适用于较小的屏幕,例如 iPhone SE 或 5S。在 iPhone 6 这样的大屏幕上,这不起作用
我想要一个菜单从右侧滑入,并且一切正常,除了它一直滑到屏幕左侧。即屏幕左侧与菜单边缘之间应该有一定距离,但距离为0。 这是我的配置: let rightSideMenu = NavigationU
当我使用代码添加 SideMenu 时,我无法 java 给我你有问题,但我无法解决问题 enter image description here 可以帮助我修复代码或给我另一个代码。 Form hi
从底部滑出和滑入侧边菜单或向上滑动模态框(Ionic2 Modal)的动画非常快速和流畅。 现在我为 float 操作按钮定义了自己的动画。此动画比 ionic 动画慢得多。有什么区别? 为什么我的动
我目前正在尝试从 V1 升级到 react-native-navigation V2,但在尝试找到一种在按下顶部栏按钮时切换侧边菜单的方法时遇到了困难。 我的应用开始于 Navigation.setR
我在 objective-c 中以编程方式创建了标签栏 Controller ,我需要实现侧边栏菜单。是否可以在标签栏 Controller 中实现侧边栏菜单? - (BOOL)application
我正在尝试制作一个侧边栏菜单,但我遇到了一个小问题。 我解释: 我创建了一个名为 sideMenuViewController 的 UIViewController 在我的 viewControlle
为什么我的Tabbar显示在另一个Sidemenu项中,这是我的代码 let navigate = storyboard?.instantiateViewController(withIdentifi
我将 CosmicMind/Material 与 SideMenu 一起使用,如本例所示:here ,但是当我按下菜单的一个单元格时,我不知道如何更改(加载)另一个 View Controller 。
我对 iOS 和 Swift 没有什么经验,我正在尝试创建一个 SlideOut 菜单,或在 Android 上调用的 NavigationDrawer。到目前为止,我正在使用这个 library (
我有一个带有 5 个屏幕的小应用程序,它们嵌入在导航堆栈中,我无法关闭 UIViewController 我正在使用 SideMenu在我的项目中展示它的最后一个 UIViewController,这
嘿,我很难使用 CSS 动画。我使用 Bootstrap 4,对网站开发和 CSS 都很陌生。我将 Animate.css 用于我的动画。我希望图标按钮扩展到一侧并显示带有选择元素的 div(用于表过
我在我的应用程序中成功使用了 SideMenu 2.3.4,然后升级到 v3.1.4。我制作了一些需要调整 API 更改的模块,然后运行我的应用程序 - 在执行以下 UI 操作后它崩溃了: 点击导航栏
我正在使用the following pod用于我的 SideMenu 功能。现在,如果我从 XYZ viewController 打开它并选择再次打开 XYZ viewController 的行,则
我正在按照 SideMenu 设置侧面菜单 首次加载应用程序时,侧面菜单 Controller 工作正常(.menuslide) 但是当我从侧面菜单回到同一个 Controller 到同一个 View
我使用侧边菜单库“kukushi/SideMenu” 我将数据发送到另一个 tableViewController (ScheduleTableVC) let navigation = UIS
我已经使用 Carthage 下载了 jonkykong SideMenu 并将 framework 导入到我的项目中,如下图所示 当我尝试将 storyboard 中的 navigation con
我有一个 ionic 应用程序,工作正常,但现在它显示出一些奇怪的行为,当我运行该应用程序时,它首先不显示数据,但当我单击侧面菜单一次或两次时,它会加载并显示数据。我有一个nodejs api,数据从
所以我有一个 TableView Controller 并使用 https://github.com/jonkykong/SideMenu我正在尝试显示一个有效的“滑入”侧边栏,但它没有显示我想要在侧
我必须使用 Vue + Typescript 为 google sides 开发一个应用程序,这是一个扩展 google sides 功能的额外菜单。这里有一个不使用 Typescript 的示例 h
我是一名优秀的程序员,十分优秀!