作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我需要为我的 UITabbar
设置 Action ,当我点击我的 tabbaritem 时,它应该转到我在另一个 View Controller 中进行的 Action 。
但它正在重定向到 UITableview
这是我的代码 -
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// create our table view controller that will display our store list
FirstViewController *firstViewController = [[EzMasterViewController alloc] init];
// create the navigation controller that will hold our store list and detail view controllers and set the store list as the root view controller
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:firstViewController];
[navController.tabBarItem setTitle:@"Home"];
[navController.tabBarItem setImage:[UIImage imageNamed:@"53-house.png"]];
SecondViewController *secondViewController = [[SecondViewController alloc] init];
// create the navigation controller that will hold our store list and detail view controllers and set the store list as the root view controller
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[navController1.tabBarItem setTitle:@"Scan"];
[navController1.tabBarItem setImage:[UIImage imageNamed:@"195-barcode.png"]];
ThirdViewController *thirdViewController = [[ThirdViewController alloc] init];
// create the navigation controller that will hold our store list and detail view controllers and set the store list as the root view controller
UINavigationController *navController2 = [[UINavigationController alloc] initWithRootViewController:thirdViewController];
[navController2.tabBarItem setTitle:@"Map"];
[navController2.tabBarItem setImage:[UIImage imageNamed:@"07-map-marker.png"]];
// add our view controllers to an array, which will retain them
NSArray *viewControllers = [NSArray arrayWithObjects:navController, navController1,navController2, nil];
// add our array of controllers to the tab bar controller
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:viewControllers];
// set the tab bar controller as our root view controller
[self.window setRootViewController:tabBarController];
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
return YES;
通过点击 SecondViewController
tabbaritem 它应该重定向到操作,操作在 FirstViewController
中。
最佳答案
您应该考虑实现 UITabBarControllerDelegate's两种方法:
– tabBarController:shouldSelectViewController:
– tabBarController:didSelectViewController:
关于objective-c - 无法以编程方式为 UITabbarItem 设置操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10926391/
在 Rails 中,您可以使用嵌套路由为 has_one 和 has_many 关系创建 RESTful 路由。可以在 Rails Guides 上找到示例 请问有没有什么好的方法可以为habtm关系
我是一名优秀的程序员,十分优秀!