@@ -38,8 +38,6 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
38
38
#import " UIView+DCTSubviewExtensions.h"
39
39
#import " UIResponder+DCTNextResponderExtensions.h"
40
40
41
- NSUInteger const DCTTabBarUnselectedIndex = -1 ;
42
-
43
41
@interface DCTTabBarController ()
44
42
- (void )dctInternal_setUpTabBarItems ;
45
43
- (void )dctInternal_sendDelegateMessageDidSelectViewController : (UIViewController *)viewController ;
@@ -74,7 +72,9 @@ - (id)init {
74
72
if (!(self = [super init ])) return nil ;
75
73
76
74
self.position = DCTContentBarPositionBottom;
77
- selectedIndex = DCTTabBarUnselectedIndex;
75
+ self.barHidden = NO ;
76
+ self.landscapeBarSize = CGSizeMake (480 .0f , 49 .0f );
77
+ self.portraitBarSize = CGSizeMake (320 .0f , 49 .0f );
78
78
79
79
return self;
80
80
}
@@ -90,11 +90,11 @@ - (void)viewDidUnload {
90
90
- (void )viewDidLoad {
91
91
[self dctInternal_setUpTabBarItems ];
92
92
self.barView = self.tabBar ;
93
- if ( self.selectedIndex == DCTTabBarUnselectedIndex) self.selectedIndex = 0 ;
93
+ self.selectedIndex = self.selectedIndex ;
94
94
self.tabBar .selectedItem = [self .tabBar.items objectAtIndex: self .selectedIndex];
95
95
self.tabBar .delegate = self;
96
96
[super viewDidLoad ];
97
- [ self loadContentView ];
97
+
98
98
viewIsLoaded = YES ;
99
99
}
100
100
@@ -140,26 +140,25 @@ - (void)setTabBarHidden:(BOOL)hidden animated:(BOOL)animated {
140
140
}
141
141
142
142
- (void )loadContentView {
143
-
144
- BOOL firstLoad = [self .contentView dct_hasSubviews ];
145
-
146
- // [self.contentView dct_removeAllSubviews];
147
-
148
- if (firstLoad) [self dctInternal_refreshNavigationControllerItems ];
143
+ if ([self isContentViewLoaded ]) [self dctInternal_refreshNavigationControllerItems ];
149
144
}
150
145
151
146
#pragma mark -
152
147
#pragma mark Accessors
153
148
154
149
- (void )setSelectedIndex : (NSUInteger )integer {
155
150
156
- if (integer == selectedIndex) return ;
151
+ BOOL firstLoad = [self isContentViewLoaded ];
152
+
153
+ if (!firstLoad && integer == selectedIndex) return ;
157
154
158
155
UIViewController *oldVC = nil ;
159
- if (selectedIndex != DCTTabBarUnselectedIndex ) oldVC = self.selectedViewController ;
156
+ if (!firstLoad ) oldVC = self.selectedViewController ;
160
157
161
158
selectedIndex = integer;
159
+
162
160
UIViewController *newVC = self.selectedViewController ;
161
+
163
162
newVC.view .frame = self.contentView .bounds ;
164
163
165
164
[oldVC viewWillDisappear: NO ];
@@ -173,7 +172,6 @@ - (void)setSelectedIndex:(NSUInteger)integer {
173
172
}
174
173
175
174
- (UIViewController *)selectedViewController {
176
- if (self.selectedIndex == DCTTabBarUnselectedIndex) self.selectedIndex = 0 ;
177
175
return [viewControllers objectAtIndex: self .selectedIndex];
178
176
}
179
177
@@ -189,7 +187,11 @@ - (void)setTabBar:(DCTTabBar *)aTabBar {
189
187
}
190
188
191
189
- (DCTTabBar *)tabBar {
192
- if (!tabBar) self.tabBar = [[DCTTabBar alloc ] initWithFrame: CGRectMake (0 .0f , 0 .0f , 320 .0f , 44 .0f )];
190
+ if (!tabBar) {
191
+ DCTTabBar *tb = [[DCTTabBar alloc ] initWithFrame: CGRectMake (0 .0f , 0 .0f , 320 .0f , 49 .0f )];
192
+ self.tabBar = tb;
193
+ [tb release ];
194
+ }
193
195
return tabBar;
194
196
}
195
197
0 commit comments