如何隐藏UITabbarIcon?

时间:2019-05-30 09:26:30

标签: ios swift uitabbarcontroller uitabbar uitabbaritem

我目前正在开发一个iOS应用,其中将包含5个标签栏图标。仅当允许您看到其中之一时,它们才应该可见。 如何隐藏该图标?

2 个答案:

答案 0 :(得分:1)

如果要从Traceback (most recent call last): File "C:\Users\ykapare\AppData\Local\Programs\Python\Python36\Scripts\git-remote-codecommit-script.py", line 11, in <module> load_entry_point('git-remote-codecommit==0.5', 'console_scripts', 'git-remote-codecommit')() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\git_remote_codecommit\__init__.py", line 152, in main context = Context.from_url(remote_url) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\git_remote_codecommit\__init__.py", line 125, in from_url credentials = session.get_credentials() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\botocore\session.py", line 399, in get_credentials 'credential_provider').load_credentials() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\botocore\credentials.py", line 1673, in load_credentials creds = provider.load() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\botocore\credentials.py", line 785, in load creds_dict = self._retrieve_credentials_using(credential_process) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\botocore\credentials.py", line 810, in _retrieve_credentials_using provider=self.METHOD, error_msg=stderr.decode('utf-8')) botocore.exceptions.CredentialRetrievalError: Error when retrieving credentials from custom-process: Traceback (most recent call last): File "c:\users\ykapare\appdata\local\programs\python\python36\lib\runpy.py", line 193, in _run_module_as_main "__main__", mod_spec) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "C:\Users\ykapare\AppData\Local\Programs\Python\Python36\Scripts\awsprocesscreds-saml.exe\__main__.py", line 9, in <module> File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\awsprocesscreds\cli.py", line 81, in saml creds = fetcher.fetch_credentials() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\awsprocesscreds\saml.py", line 353, in fetch_credentials creds = super(SAMLCredentialFetcher, self).fetch_credentials() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\botocore\credentials.py", line 566, in fetch_credentials return self._get_cached_credentials() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\botocore\credentials.py", line 576, in _get_cached_credentials response = self._get_credentials() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\awsprocesscreds\saml.py", line 362, in _get_credentials kwargs = self._get_assume_role_kwargs() File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\awsprocesscreds\saml.py", line 403, in _get_assume_role_kwargs assertion = self._authenticator.retrieve_saml_assertion(config) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\awsprocesscreds\saml.py", line 139, in retrieve_saml_assertion endpoint) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\awsprocesscreds\saml.py", line 150, in _retrieve_login_form_from_endpoint response = self._requests_session.get(endpoint, verify=True) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\requests\sessions.py", line 546, in get return self.request('GET', url, **kwargs) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\requests\sessions.py", line 533, in request resp = self.send(prep, **send_kwargs) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\requests\sessions.py", line 640, in send adapter = self.get_adapter(url=request.url) File "c:\users\ykapare\appdata\local\programs\python\python36\lib\site-packages\requests\sessions.py", line 731, in get_adapter raise InvalidSchema("No connection adapters were found for '%s'" % url) requests.exceptions.InvalidSchema: No connection adapters were found for ''https://x.x.x.x/adfs/ls/IdpInitiatedSignOn.aspx?loginToRp=urn:amazon:webservices'' 中删除UIViewController,请在tabBar

中添加以下代码行

要删除

UITabBarControllerClass

添加

self.viewControllers?.remove(at: tabIndex) // replace the tabIndex which you want to remove

答案 1 :(得分:0)

使用以下代码,您可以从标签栏删除指定的标签:

let tabIndex = 3
if let tabBarController = self.tabBarController {
    if tabIndex < tabBarController.viewControllers?.count {
        var allViewControllers = tabBarController.viewControllers
        allViewControllers?.remove(at: tabIndex)
        tabBarController.viewControllers = allViewControllers
    }
}