FacebookのiOSサイドメニューを模倣して機能させようとしていますが、SO iphone)の別の質問で説明されているように、サイドメニューを後ろに送信できないという問題があります。 Objective Cを使用したFacebookサイドメニュー 。提案されたライブラリを使用していませんが、代わりに提案されたコードを使用しています。
- (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.
}
サイドメニューが必要なコントローラーで、ビューを後ろに移動するのではなく、現在のビューにロードされているように見えるので、メニューをスライドすると表示されます。
誰かがmyDelegateビューを後ろに表示するのを手伝ってもらえますか?
あなたが何を達成しようとしているのか完全にはわからないので、推測する必要があります。 myDelegate.view
をself.view
の後ろに隠したいようです。このようには機能しません。
sendSubviewToBack:
は、サブビューをビュー階層の後ろに送信します送信者の、あなたの場合はself.view
。スーパービューの下にサブビューを送信することはありません。
代わりに、myDelegate.view
をサブビューとしてself.view
sスーパービューに追加し、それをself.view
の後ろに置くことができます。
[[self.view superview] insertSubview:myDelegate.view belowSubview:self.view];