Hi I want implement this animation effect(using storyboard), when user click a tab bar(say 2nd tab bar item), it displays the corresponding view like a modal view(display upwards to the screen)
My current method is delegate tab bar controller to tab bar and rewrite
-(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];
}
}
The problem is, the view displayed is a black screen, any idea how to implement it correctly?
my source code can be found a link below: https://www.dropbox.com/s/6rd6ek59xf0yiq4/testtabbar.zip
Change the lines :
CBTab2ViewController* modalViewController = [[CBTab2ViewController alloc] init];
[self presentViewController:modalViewController animated:YES completion:nil];
To this one (incase your storyboard name is "MainStoryBoard"):
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard"
bundle: nil];
CBTab2ViewController * modalViewController = (MyViewController*)[mainStoryboard
instantiateViewControllerWithIdentifier: @"CBTab2ViewController"];
[self presentViewController:modalViewController animated:YES completion:nil];
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.