我有一个tableviewcontroller,在tableviewcontroller的相应rowclick上,我想显示该相应行的详细信息的细节。
行详细信息视图将具有固定的内容,如下所示:
在上述几点中,第1-3点的内容将覆盖固定位置的ViewController的页面的一半,并且ViewController的下半部分将具有第4个点,即各个选项卡按钮的视图将根据为各个选项卡创建的视图而改变。
我无法找到任何解决方案来固定视图的上半部分。以及如何将标签栏的视图限制在屏幕的下半部分。
我在不使用Storyboard的情况下执行此应用程序。
搜索了很多,但没有任何解决方案。
请提供一些示例代码或教程(如果有)。
以下是我确切想要的图像,因为我在android中创建了相同的图像。
抱歉,需要模糊图像的内容。
在上图中,以下是我要修复的问题:
My question is i want the first 2 of above points be fixed and the viewcontroller containing the views for respective tabbarbuttons should be seen on the rest half of the screen with the 4 tabbar buttons.
So if i click on any of the tab buttons only its view which is occupied by bottom half of the screen will change & the top half will remain static(fixed).
Hope my explaination make clear some doubts about the question.
----EDITED SOLUTION based on what @Simon McLoughlin suggested, following is the code:
I have implemented a function in which i have written code for implementing my scenario.
-(void)loadShowDetailsTabBarController
{
ConceptViewController *conceptViewController;
CastViewController *castViewController;
ShowDetailsFeedbackViewController *showDetailsFeedbackViewController;
PromosViewController *promoViewController;
UIImage *conceptBtn = [UIImage imageNamed:@"showdetailstabidle_btn_bg.png"];
UIImage *conceptBtnSelected = [UIImage imageNamed:@"showdetailstabselected_btn_bg.png"];
UIImage *castBtn = [UIImage imageNamed:@"showdetailstabidle_btn_bg.png"];
UIImage *castBtnSelected = [UIImage imageNamed:@"showdetailstabselected_btn_bg.png"];
UIImage *feedbackBtn = [UIImage imageNamed:@"showdetailstabidle_btn_bg.png"];
UIImage *feedbackBtnSelected = [UIImage imageNamed:@"showdetailstabselected_btn_bg.png"];
UIImage *promoBtn = [UIImage imageNamed:@"showdetailstabidle_btn_bg.png"];
UIImage *promoBtnSelected = [UIImage imageNamed:@"showdetailstabselected_btn_bg.png"];
conceptBtn = [conceptBtn imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
conceptBtnSelected = [conceptBtnSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
castBtn = [castBtn imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
castBtnSelected = [castBtnSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
feedbackBtn = [feedbackBtn imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
feedbackBtnSelected = [feedbackBtnSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
promoBtn = [promoBtn imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
promoBtnSelected = [promoBtnSelected imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
{
conceptViewController = [[ConceptViewController alloc] initWithNibName:@"ConceptViewController_iPad" bundle:nil];
castViewController = [[CastViewController alloc] initWithNibName:@"CastViewController_iPad" bundle:nil];
showDetailsFeedbackViewController = [[ShowDetailsFeedbackViewController alloc] initWithNibName:@"ShowDetailsFeedbackViewController_iPad" bundle:nil];
promoViewController = [[PromosViewController alloc] initWithNibName:@"PromosViewController_iPad" bundle:nil];
}
else if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
conceptViewController = [[ConceptViewController alloc] initWithNibName:@"ConceptViewController" bundle:nil];
castViewController = [[CastViewController alloc] initWithNibName:@"CastViewController" bundle:nil];
showDetailsFeedbackViewController = [[ShowDetailsFeedbackViewController alloc] initWithNibName:@"ShowDetailsFeedbackViewController" bundle:nil];
promoViewController = [[PromosViewController alloc] initWithNibName:@"PromosViewController" bundle:nil];
}
conceptViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"CONCEPT" image:conceptBtn selectedImage:conceptBtn];
castViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"CAST" image:castBtn selectedImage:castBtnSelected];
showDetailsFeedbackViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"FEEDBACK" image:feedbackBtn selectedImage:feedbackBtnSelected];
promoViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"PROMO" image:promoBtn selectedImage:promoBtnSelected];/**/
UITabBarController *showDetailstabVC = [[UITabBarController alloc] init];
showDetailstabVC.viewControllers = [NSArray arrayWithObjects:conceptViewController,castViewController,showDetailsFeedbackViewController,promoViewController, nil];
showDetailstabVC.view.frame = CGRectMake(0, 250, screenSize.width, screenSize.height-250);
self.view.window.rootViewController = showDetailstabVC;
[self.view addSubview:showDetailstabVC.view];
}
Please let me know if my code is correct?
I am able to view what i wanted.
But now the problem is when i click on the tabbar buttons i get the following error:
exc_bad_access (code=exc_i386_gpflt)
The error is not given in debug screen, The app stops at the following line in main.m :
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
Ok so it turns out what you are trying to achieve is a UIViewController
split vertically. Top half being static and bottom half containing a UITabbarController
that will display UIViewControllers
that will only occupy the space between the UITabbar
and the static view.
I thought this could be done with making the UITabbarController
a child, but I could be wrong. I have had 3 child UIViewController
's on a screen before by simply setting the frame. You've said above that that didn't work for you so I see 2 options left.
You create all of the tabs content to be smaller. So for example say the top view is 100px in height. In the UIViewController
's in the tabs, simply set the frame of the UITableView
(or the view or whatever the content is) to start at 100px for its Y
value. This is a fairly bad solution in my opinion however it would require the least effort to do.
You create a "Master" UIViewController
that has a static section at the top and a horizontally scrolling UIScrollView
with paging enabled. And add the individual UIViewController
's as child viewControllers to that. Not sure if you could create a Tabbar
and listen for events and use that to programmtically scroll it, or if you would have to create your own UIView
that looks like a Tabbar
and put buttons on it to scroll left / right.
第二种方法是很常见的事情。我已经完成了一些应用程序,并且在网上看到了很多有关如何实现它的帖子。像这样:如何将viewController放入UIScrollView中。它只是需要以增加的X
值添加子viewControllers并将scrollViews内容大小设置为total。打开Pagging,关闭垂直滚动。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句