I have done a bit of research but can't get this thing to work. Perhaps if i post my code someone can point out the flaw.....I appreciate your help.
As you guessed.....I have A UITabBarController, it has 5 tabs. What im trying to do is: User selects TabBar Tab number 4 and it calls webservice to update my TableView. The call to server works fine,(it has been tested in ViewDidLoad), But I want it to call to server each time the user selects the tab.........Just can't figure out the Delegate for TabBar, it appears as though the didSelectViewController method is not working properly. See my code if you think you can help....
blt_applicationAppDelegate.h
blt_applicationAppDelegate.m
ViewController.h
ViewContoller.m
Thank you in advance for any help.
As you guessed.....I have A UITabBarController, it has 5 tabs. What im trying to do is: User selects TabBar Tab number 4 and it calls webservice to update my TableView. The call to server works fine,(it has been tested in ViewDidLoad), But I want it to call to server each time the user selects the tab.........Just can't figure out the Delegate for TabBar, it appears as though the didSelectViewController method is not working properly. See my code if you think you can help....
blt_applicationAppDelegate.h
Code:
#import <UIKit/UIKit.h>
@interface blt_applicationAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
UIWindow *window;
IBOutlet UITabBarController *rootController;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) UITabBarController *rootController;
@end
blt_applicationAppDelegate.m
Code:
#import "blt_applicationAppDelegate.h"
#import "ViewController.h"
@implementation blt_applicationAppDelegate
@synthesize window;
@synthesize rootController;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[window addSubview:rootController.view];
[rootController setDelegate:self];
[window makeKeyAndVisible];
}
- (void)dealloc {
[rootController release];
[window release];
[super dealloc];
}
@end
ViewController.h
Code:
#import <UIKit/UIKit.h>
@class blt_applicationAppDelegate;
@interface ViewController : UITableViewController {
blt_applicationAppDelegate *appDelegate;
}
@end
ViewContoller.m
Code:
#import "ViewController.h"
#import "blt_applicationAppDelegate.h"
@implementation ViewController;
- (void)tabBarController:(UITabBarController *)rootController didSelectViewController:(UIViewController *)viewController {
if (1 == 1)
{
*********my code to call webservice*******
}
}
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)dealloc {
[appDelegate release];
[super dealloc];
}
@end
Thank you in advance for any help.