UISegmentedControl Problem

Discussion in 'iOS Development' started by Steaps, Mar 10, 2009.

  1. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    No matter where i put this, it crashes the application, opens then closes. I have tried viewDidLoad, as well as inside my tableViewCell.
    Code:
    	NSArray *segmentTextContent = [NSArray arrayWithObjects: @"First", @"Second", @"Third", nil];
    	UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent];
    	segmentedControl.frame = CGRectMake(0, 0, 100, 50);
    	[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
    	segmentedControl.segmentedControlStyle = UISegmentedControlStyleBordered;
    	segmentedControl.selectedSegmentIndex = 1;
    	[self.view addSubview:segmentedControl];
    What am i doing wrong?

    Thanks.
  2. NolesFans

    NolesFans New Member

    Joined:
    Sep 23, 2008
    Messages:
    404
    Likes Received:
    0
    Device:
    iPod touch
    so you want to selected Second?

    did you have
    Code:
    - (void)segmentAction:(id)sender
    too?
  3. Steaps

    Steaps New Member

    Joined:
    Oct 24, 2007
    Messages:
    5,074
    Likes Received:
    41
    Device:
    iPod touch
    I fixed it last night, but yes, that was the problem.

Share This Page