ios


Hide TabBar Item #2 after collectionView reload Objective C


I have 2 collection views in 2 separate viewcontrollers which is inside a tabbar. I'm trying to hide tabbar item 2, until tabbar 1 is loaded. Do we have any way to hide a certain tab bar item?? Initially in viewWillAppear I want to hide tabBar Item.. Here is the code that I have :
Hide Tab Bar 2
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
//HIDE TABBAR2
}
Show Tab Bar 2
- (void)loadCollectionView
{
[self.collectionView reloadData];
[self.collectionView performBatchUpdates:^{}
completion:^(BOOL finished) {
//Unhide TabBar
}];
}
You need to remove that view controller from your tabbar, you cant hide specific tabbar item! So you can manage it like,
NSMutableArray *viewControllersArr = [self.tabBarController.viewControllers mutableCopy];
[viewControllersArr removeObjectAtIndex:1];
[self.tabBarController setViewControllers:viewControllersArr animated:YES];
and when you get your collection view data or when you want to show second tab then you can do like
NSMutableArray *viewControllersArr = [self.tabBarController.viewControllers mutableCopy];
UIViewController *yourSeconVc = [self.storyboard instantiateViewControllerWithIdentifier:#"yourStoryboardIdentifier"]; // or whatever way your view controller is for second tab
[viewControllersArr addObject:yourSeconVc];
[self.tabBarController setViewControllers:viewControllersArr animated:YES];
Try this code
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[_tabController setViewControllers:#[viewcontroller1,viewcontroller3]];
}
Show Tab 2 here
- (void)loadCollectionView
{
[self.collectionView reloadData];
[self.collectionView performBatchUpdates:^{}
completion:^(BOOL finished)
{
[_tabController setViewControllers:#[viewcontroller1,viewcontroller2,viewcontroller3]];
}];
}
Subclass a UITabBarController (call it e.g. MainTabController). In interface builder set the class type of your tab bar controller object to be of type MainTabController.
In MainTabController create a strong property to store the second view controller (the one that will be hidden):
#property (nonatomic, strong) UIViewController *secondTabVC;
Then in viewDidLoad:
// Store the second tab's VC for later
self.secondTabVC = self.viewControllers[1];
// Hide the second tab's VC
self.viewControllers = #[self.viewControllers[0]];
Once your data has loaded:
// Show the second tab's VC
self.viewControllers = #[self.viewControllers[0], self.secondTabVC];

Related Links

How to add SDWebImagePrefetcher in swift
Unicode not working properly in iOS
Selecting a word and shows tooltip in iOS
UIBarButtonIteem common to all controllers
App ID Prefix at apple developer
What happens if I use accessibilityIdentifier and accessibilityLabel on same element
Migrating my app to 64 bit with parse and I get this link error that is driving me crazy
Calculating distance between two PFGeoPoints in Swift
Why isn't func motionEnded not working in GameScene?
moving UINavigationBar frame causes unrecognizable clicks
Why is (form.$error && form.$submitted) true on start?
How to keep objects in NSMutableArray?
Parse::UserCannotBeAlteredWithoutSessionError 206 iOS
iOS - How to Control the Kind of Animation in an Unwind Segue?
Flurry Ads Not Showing Up
UICollectionview cellForItemAtIndexPath not getting called when reload in iOS 8

Categories

HOME
opencv
serial-port
apache-pig
outlook
styling
android-bluetooth
binary-search
zipfile
superfish
research
uwsgi
obiee
eloqua
highlight
union
avr
apex
jsqmessagesviewcontroller
partitioning
aar
zap
appcelerator-alloy
jscodeshift
aspdotnetstorefront
core-location
shape
unsigned-integer
paket
flexjs
memorystream
trial
meanjs
graphql-dotnet
sql-server-2014-express
json-c
pvlib
petrel
edit-distance
azure-app-service-envrmnt
macvim
perl-module
ipod-touch
jsonstore
extjs4
visualsvn-server
eve
syncfusion
mergesort
maven-jetty-plugin
ase
appdynamics
dependency-management
rating-system
requirements-management
domdocument
stroke
simple.odata.client
ternary
playback
graph-traversal
mink
proc
git-config
business-logic
turnjs
struts1
restbed
python-3.1
duration
vb6-migration
jongo
rabbitvcs
okuma
flexigrid
genetic
document-ready
gulp-protractor
viennacl
mailx
keypad
gem
android-print-framework
windows-universal
alt
declaration
isql
horizontalscrollview
esx
concurrentdictionary
dynamic-typing
linguistics
datacontractserializer
aps
spread-toolkit
xcode6.1.1
jqgrid-php
fay
django-endless-pagination
couchrest
libtorrent-rasterbar
mod-python
nsusernotificationcenter
programmers-notepad
zephir
scrollpane
jflow
chromeless
progressdialog
datadesign
icon-fonts
gigaspaces
freeglut
google-profiles-api
mknetworkkit
jscience
server.mappath
dired
directoryentry
automapping
markitup
pinging
mud

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App