[英]ios tab bar click to show modal view get a black screen
嗨,我想實現這個動畫效果(使用故事板),當用戶點擊標簽欄(比如第二個標簽欄項)時,它會像模態視圖一樣顯示相應的視圖(向上顯示到屏幕)
我當前的方法是委托標簽欄控制器到標簽欄並重寫
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{
NSLog(@"rawr");
NSLog(@"inside tab bar did select, index is %d", self.selectedIndex);
if (item == [self.tabBar.items objectAtIndex:1]) {
//item.title = @"modal view";
NSLog(@"going to promote as modal view");
CBTab2ViewController* modalViewController = [[CBTab2ViewController alloc] init];
[self presentViewController:modalViewController animated:YES completion:nil];
}
}
問題是,顯示的視圖是黑屏,任何想法如何正確實現?
我的源代碼可以在下面找到一個鏈接: https : //www.dropbox.com/s/6rd6ek59xf0yiq4/testtabbar.zip
改變線條:
CBTab2ViewController* modalViewController = [[CBTab2ViewController alloc] init];
[self presentViewController:modalViewController animated:YES completion:nil];
對於這個(因為你的故事板名稱是“MainStoryBoard”):
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
CBTab2ViewController * modalViewController = (MyViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"CBTab2ViewController"];
[self presentViewController:modalViewController animated:YES completion:nil];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.