我試圖從另一個類打印這個值,但它始終顯示所選的tabbar
索引爲0爲什麼Tabbar選擇的項目總是0?
爲什麼?有沒有其他方法可以確定現在選擇哪個選項卡?
在我的第二類tableviewcontroller
didselect
`方法,我試圖打印以下行
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
sharedManager=[Mymanager sharedManager];
sharedManager.navigationBarTitle=[name objectAtIndex:indexPath.row];
NSLog(@"%d",self.tabBarController.selectedIndex);
}
,但它始終顯示?
我需要不同的索引不同的標籤?
我的意圖是確定選項卡和調用方法現在我改變,調用四個不同的methodes 但當我創建一個對象,並試圖調用方法,它不顯示爲什麼?
我APpdelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[NSThread sleepForTimeInterval:5.0];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
[[NSNotificationCenter defaultCenter] postNotificationName:@"internet connection" object:self];
dispatch_queue_t connectivityThread = dispatch_queue_create("com.ttt.test.connectivity", NULL);
dispatch_async(connectivityThread, ^{
while (true){
if([GMMConnectivity hasConnectivity])
[[NSNotificationCenter defaultCenter] postNotificationName:@"InternetCheck" object:[NSNumber numberWithBool:YES]];
else
[[NSNotificationCenter defaultCenter] postNotificationName:@"InternetCheck" object:[NSNumber numberWithBool:NO]];
usleep(5000000);
}
});
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
//-(void)recentPages:(NSString *)pageNumber
//{
// //NSLog(@"%@",pageNumber);
//}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
你肯定self.tabBarController不是零? – rdelmar
它的0 ..值是0 – Navi
我敢肯定你錯誤'UITabBar' UITableView'。 – Cyrille