Segmented Control to change webview?

Discussion in 'iOS Programming' started by newtoiphonesdk, Sep 16, 2010.

  1. newtoiphonesdk macrumors 6502a

    Jul 30, 2010
    I want about 3 different blog pages on one tab of my tab bar application. I'd like to have the segmentedcontrol setup to handle this. So far, I have made 3 different view classes, each with a webview that points to a different blog. On the FirstTabViewController I declared the class of all 3 views and set up an IBOutlet for each one. I also declared the IBOutlet for the segmentedcontrol, and hooked up all connections in IB. In the .m file I am running this code:
    - (IBAction)changesegment {
    	if (segment.selectedSegmentIndex == 0) {
    		[self addSubview: blog1];
    	if (segment.selectedSegmentIndex == 1) {
    		[self addSubview: blog2];
    	if (segment.selectedSegmentIndex == 2) {
    		[self addSubview: blog3];
    But, I can't get it to work. Any ideas?
  2. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    Why not just have one viewController with a webView and you change the content (url) based on the desired segment?

    You'll need to be a little more specific. What's not working? Errors, warnings, etc.?
  3. newtoiphonesdk thread starter macrumors 6502a

    Jul 30, 2010
    I have it working now

Share This Page