/ Published in: Objective C
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#define ACTIONEDIT 0 #define ACTIONADD 1 ... UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] [UIImage imageNamed:@"icon-edit.png"], [UIImage imageNamed:@"icon-add.png"], nil] ]; [segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged]; segmentedControl.frame = CGRectMake(0, 0, 90, 30); segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; segmentedControl.momentary = YES; [segmentedControl setEnabled:YES forSegmentAtIndex:ACTIONEDIT]; self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl]; ... - (void)segmentAction:(id)sender { UISegmentedControl* segCtl = sender; int action = [segCtl selectedSegmentIndex]; switch (action) { case ACTIONADD: [self addToList]; break; case ACTIONEDIT: [self editList]; break; } }