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

Unknown Selector Issue
How to crop my App image like iPhone photo gallary
iOS: How to subscribe a customer to an Automatically Renewable Subscription
Add objects into array from UITableViewCell
Moving view closer to camera
My session.dataTaskWithRequest method is not returning any data
How to fetch all WiFi connection
Swift 2 Static UICollectionView change to Json Parsing UICollectionView
MyApp-Swift.h file not found. for a specific class only
Realm- updating all items in array of objects instead of appending only new one
Show Interstitial In Other Scenes - Admob, SpriteKit, Swift
Control table views inside a single collection view cell
Set CheckBox on - off
Custom Class View for UIButton
dispatch task into queue in order to run the task in another thread [duplicate]
How to compare PHAsset to UIImage

Categories

HOME
ssl
embedded-linux
selenium
svg
web-services
module
order
blogs
stack
wso2is
netbeans-8
freebsd
silverlight
google-maps-sdk-ios
overloading
command-line-arguments
asp.net-mvc-5.2
lazy-loading
amplitude
nxbre
aikau
csom
weather-api
stylesheet
memorystream
silverlight-5.0
google-shared-contacts
stackexchange.exceptional
nib
google-domain-api
gridstack
p4-lang
folly
paypal-rest-sdk
kmdf
joe-editor
runc
ulimit
freerdp
angularjs-routing
quicksand
wp-api
http-status-code-500
jquery-masonry
htc
cmsmadesimple
zenity
agile-processes
tfs2008
surroundscm
ultratree
business-logic
struts1
vlc-android
app-engine-ndb
vb6-migration
winobjc
xlform
asp.net-webpages
js-of-ocaml
occam-pi
flexigrid
openocd
rdotnet
chunk-templates
xsb
wss4j
cbc-mode
size-t
pencilblue
diagonal
iscroll4
jasmin
globus-toolkit
custom-titlebar
disk-io
validform
lightstreamer
junit-runner
sqlprofiler
nmea
location-client
mms-gateway
geometry-surface
google-authorship
virtual-earth
html5-apps
clean-urls
makumba
expressionvisitor
bapi
android-assets
exact-synergy-enterprise
soapheader
retain
orthographic
nstreecontroller
pastebin
apache-config
xlink

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