Posted By

espinallab on 04/18/10


Tagged

in UISegmentedControl UINavigationItem


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

umang_nine


UISegmentedControl in UINavigationItem


 / Published in: Objective C
 

URL: http://www.iphonedevsdk.com/forum/iphone-sdk-development/3057-uisegmentedcontrol-uinavigationitem.html

This works for me!

  1. UISegmentedControl *segmentedControl = [[UISegmentedControl alloc] initWithItems:
  2. [NSArray arrayWithObjects:
  3. [UIImage imageNamed:K_IMAGE_UPARROW],
  4. [UIImage imageNamed:K_IMAGE_DOWNARROW],
  5. nil]];
  6. //[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
  7. segmentedControl.frame = CGRectMake(0, 0, 90, 30);
  8. segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
  9. segmentedControl.momentary = YES;
  10.  
  11. UIBarButtonItem *segmentBarItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];
  12. [segmentedControl release];
  13.  
  14. self.navigationItem.rightBarButtonItem = segmentBarItem;
  15. [segmentBarItem release];

Report this snippet  

You need to login to post a comment.