Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

kwjohns

macrumors 6502a
Original poster
Jul 4, 2007
700
12
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:

segments.png


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];
}
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.