Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iOS SDK中隐藏选项卡栏时,如何将中心按钮添加到UITabBar并将其隐藏?_Ios_Iphone_Tabbar - Fatal编程技术网

在iOS SDK中隐藏选项卡栏时,如何将中心按钮添加到UITabBar并将其隐藏?

在iOS SDK中隐藏选项卡栏时,如何将中心按钮添加到UITabBar并将其隐藏?,ios,iphone,tabbar,Ios,Iphone,Tabbar,我正在使用自定义选项卡栏。我使用以下代码在选项卡栏中间添加了按钮: button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; button.frame = CGRectMake(0,0,50,50); [button setBackgroundImage:[UIImage imageNamed:@"uploader_disabled.png"] forState:UIControlStateNormal]; [button setBa

我正在使用自定义选项卡栏。我使用以下代码在选项卡栏中间添加了按钮:

button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.frame = CGRectMake(0,0,50,50);
[button setBackgroundImage:[UIImage imageNamed:@"uploader_disabled.png"] forState:UIControlStateNormal];
[button setBackgroundImage:[UIImage imageNamed:@"uploader_enabled.png"] forState:UIControlStateHighlighted];
[button addTarget:self action:@selector(OpenActionSheet) forControlEvents:UIControlEventTouchUpInside];
CGFloat heightDifference = button.frame.size.height - self.tabBar.frame.size.height;
if (heightDifference < 0)
{
    button.center = self.tabBar.center;
    NSLog(@"heightDifference");
}
else
{
    NSLog(@"not heightDifference");

    CGPoint center = self.tabBar.center;
    center.y = center.y - heightDifference/2.0;
    button.center = center;
}

[self.view addSubview:button];
现在,当我隐藏选项卡栏时,该按钮不会被隐藏。 它在所有视图控制器中都可见


如果您能帮助解决此问题,我将不胜感激。

您正在添加self.view上的按钮。你应该在tabbar上做广告


您可以这样添加。将按钮添加到tabbar控件,如下所示。之后可以隐藏Uitabbar
[myTabBarController.view addSubview:myButton]

是的,如果我使用这个“[self.tabBar addSubview:button],则按钮不显示。。。我正在使用[self.view addSubview:button]`显示中心按钮。我的问题是当我使用hide push tabbar时,如何隐藏此中心按钮。。你能帮我解决这个问题吗?我四处搜索,但没有找到任何解决方案。在这方面有什么帮助吗
[self.tabBar addSubview:button];