Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your question could be more clear, but here's my best guess at an answer. This assumes the UISegmentedControl is a property called yourSegmentedControl and has been allocated (preferably by a proper getter).</p> <p>Update enabled/disabled:</p> <pre><code>[self.yourSegmentedControl setEnabled:aBOOL forSegmentAtIndex:anInt]; </code></pre> <p>Update title:</p> <pre><code>[self.yourSegmentedControl setTitle:aString forSegmentAtIndex:anInt]; </code></pre> <p>That said, your code could be simpler. If you put the UISegmentedControl in the UIViewController rather than the appDelegate you can take advantage of using the toolbarItems property to attach the control to the navigation controller. This next code isn't <em>exactly</em> your question, but may be instructive:</p> <pre><code>@interface StocksTableViewController() @property (nonatomic, strong) IBOutlet UISegmentedControl *stockFilterSegmentedControl; @end @implementation StocksTableViewController @synthesize stockFilterSegmentedControl = _stockFilterSegmentedControl; - (UISegmentedControl*)stockFilterSegmentedControl { if (!_stockFilterSegmentedControl) { _stockFilterSegmentedControl = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObjects:@"All",@"Holdings", @"To Do", nil]]; [_stockFilterSegmentedControl addTarget:self action:@selector(stockFilterControlPressed:) forControlEvents:UIControlEventValueChanged]; _stockFilterSegmentedControl.selectedSegmentIndex = 0; _stockFilterSegmentedControl.autoresizingMask = UIViewAutoresizingFlexibleHeight; _stockFilterSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; } return _stockFilterSegmentedControl; } - (NSArray*)navFooterToolbarArray { UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.stockFilterSegmentedControl]; UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:self action:nil]; UIBarButtonItem *refresh = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(refresh:)]; return [NSArray arrayWithObjects:flexibleSpace, barButtonItem, flexibleSpace, refresh, nil]; } - (void)viewDidLoad { [super viewDidLoad]; self.toolbarItems = [self navFooterToolbarArray]; } </code></pre> <p>Enjoy,</p> <p>Damien</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload