发送子视图回来 [英] Send subview to back

查看:110
本文介绍了发送子视图回来的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试模仿facebook ios侧面菜单并让它正常工作但是我遇到的问题是我无法将侧面菜单发送到后面,如另一个问题所讨论的那样使用目标c的iphone facebook侧边菜单。我没有使用建议的库,而是使用建议的代码。我有

I'm trying to mimic the facebook ios side menu and have it working however the issue I am having is that I cannot send the sidemenu to the back as discussed in another question on SO iphone facebook side menu using objective c. I'm not using the library suggested but instead using the code that was suggested. I have

- (void)viewDidLoad
{
    NSLog(@"View Did Load is running");
    activitySpinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
    activitySpinner.frame = CGRectMake(0.0, 0.0, 40.0, 40.0);
    activitySpinner.center = self.view.center;
    [self.view addSubview:activitySpinner];

    SideMenuView *myDelegate = [[SideMenuView alloc] init];
    [self setSideMenuDelegate:myDelegate];
    //set the delegate's currentViewController property so that we can add a subview to this View. 
    [sideMenuDelegate setCurrentViewController:self];

    //sideMenu = [[SideMenuView alloc] initWithNibName:@"SideMenuView" bundle:nil];
    [self.view addSubview:myDelegate.view];
    [self.view sendSubviewToBack:myDelegate.view];

    [super viewDidLoad];
    self.searchDisplayController.searchBar.scopeButtonTitles = nil;

    [self fetchCustomers];
    // Do any additional setup after loading the view, typically from a nib.
}

在我想要侧边菜单的控制器中,但视图似乎已加载进入当前视图而不是仅仅转到后面所以当我滑动菜单时可以看到它。

In my controller where I want the side menu but the view seems to get loaded into the current view instead of just going to the back so it can be seen when I slide the menu over.

有人可以帮我把myDelegate视图放到后面吗?

Can someone help me get the myDelegate view to the back?

推荐答案

我不完全确定你想要完成什么,所以我必须猜测。听起来你想在 self.view 后隐藏 myDelegate.view 。它不会以这种方式工作。

I am not entirely sure what you are trying to accomplish, so I have to guess. It sounds like you want to hide myDelegate.view behind self.view. It won't work this way.

sendSubviewToBack:将子视图发送到视图层次结构的后面发件人,在您的情况下, self.view 。它永远不会在超级视图下面发送子视图。

sendSubviewToBack: sends the subview to the back of the view hierarchy of the sender, in your case, self.view. It will never send a subview below its superview.

您可以将 myDelegate.view 作为子视图添加到 self.view s superview,并将其置于 self.view

You can instead add myDelegate.view as a subview to self.views superview, and put it behind self.view:

[[self.view superview] insertSubview:myDelegate.view belowSubview:self.view];

这篇关于发送子视图回来的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆