Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Oct 17, 2009, 06:29 AM   #1
John Baughman
macrumors member
 
Join Date: Oct 2003
editButtonItem in a segmented control?

Using...

self.navigationItem.leftBarButtonItem = self.editButtonItem;

I have an edit button in my navigation bar that works great but I would like to put it in a segmented control with an Add button. Is this possible?

As far as I can tell, the answer is no.

Thanks,

John
John Baughman is offline   0 Reply With Quote
Old Oct 17, 2009, 01:28 PM   #2
dejo
Moderator
 
dejo's Avatar
 
Join Date: Sep 2004
Location: The Centennial State
Quote:
Originally Posted by John Baughman View Post
I have an edit button in my navigation bar that works great but I would like to put it in a segmented control with an Add button. Is this possible?
Yes, it's possible, via the customView property of UIBarButtonItem. Check the NavBar sample app for how you might do this.
__________________
dejo is offline   0 Reply With Quote
Old Oct 17, 2009, 08:29 PM   #3
John Baughman
Thread Starter
macrumors member
 
Join Date: Oct 2003
Quote:
Originally Posted by dejo View Post
Yes, it's possible, via the customView property of UIBarButtonItem. Check the NavBar sample app for how you might do this.
I have successfully created a 2 button segmented control like this...

Code:
segmentedControl = [ [ UISegmentedControl alloc ] initWithItems: nil ]; 
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar; 
[ segmentedControl insertSegmentWithTitle: @"Prefs" atIndex: 0 
										 animated: NO ]; 
[ segmentedControl insertSegmentWithTitle: @"Add" atIndex: 1 
										 animated: NO ]; 
		
[ segmentedControl addTarget: self action: @selector(segmentedControlPressed:) 
		forControlEvents:UIControlEventValueChanged ];
		
UIBarButtonItem *segmentItem = [[UIBarButtonItem alloc] initWithCustomView:segmentedControl];

self.navigationItem.rightBarButtonItem = segmentItem;

[segmentedControl release];
[segmentItem release];
What I want to do is replace the Pref button at index 0 with an Edit button created with self.editButtonItem, ie with all the default behavior of an Edit button. The only way I can find to add items to the segment is with title, image, or items (array with images or titles).

John
John Baughman is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > iPhone/iPad Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Music control buttons not working in control centre (ios 7 GM) macness iOS 7 13 Sep 26, 2013 09:35 AM
Segmented Control iOS Ryan Burgess iPhone/iPad Programming 6 Jul 28, 2013 09:39 PM
Current options for segmented AND multithreaded FTP clients? amphibious Mac Applications and Mac App Store 0 Jun 7, 2013 02:59 PM
iPhoto - How are Events segmented uptownnyc Mac Applications and Mac App Store 0 Jan 23, 2013 08:45 AM
Mac crashes when using control panel, expose or mission control AdamTwosleeves Mac OS X 10.7 Lion 1 Aug 21, 2012 11:17 PM

Forum Jump

All times are GMT -5. The time now is 04:31 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC