I have a segmented control in a navigation controller and it loads up fine and I can click on one of the other tabs and it will change the webpage but as soon as I click on another or back to the original, the segments blank out into this:
I'm pretty sure there's a line of code missing in here somewhere but I can't figure out what it is.
I'm pretty sure there's a line of code missing in here somewhere but I can't figure out what it is.
Code:
- (void)viewDidLoad {
UISegmentedControl *segmentControl = self.navigationItem.titleView;
[segmentControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
selectedSegment = [segmentControl selectedSegmentIndex];
self.navigationItem.titleView = segmentControl;
NSString *urlAddress = @"http://";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[newsWebView loadRequest:requestObj];
[segmentControl release];
[super viewDidLoad];
}
-(void)segmentAction:(id)sender {
UISegmentedControl *segmentControl = sender;
selectedSegment = [segmentControl selectedSegmentIndex];
NSString *urlAddress = @"http://";
if (selectedSegment == 0) {
urlAddress = @"http://";
}
else if (selectedSegment == 1) {
urlAddress = @"http://";
}
else if (selectedSegment == 2) {
urlAddress = @"http://";
}
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[newsWebView loadRequest:requestObj];
[segmentControl release];
}