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 online now   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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
table views in a segmented controller ljg93 iPhone/iPad Programming 5 Aug 28, 2011 03:38 PM
Segmented control in a navigation bar MACloop iPhone/iPad Programming 4 Jan 11, 2010 06:56 AM
Is there a vertical segmented control? fenrus110 iPhone/iPad Programming 3 Dec 2, 2008 03:13 PM
Good example using a UISwitch or segmented control in IB? nottooshabby iPhone/iPad Programming 2 Sep 22, 2008 05:17 PM
Segmented Controls... ArtOfWarfare iPhone/iPad Programming 10 Aug 14, 2008 12:25 PM


All times are GMT -5. The time now is 09:45 AM.

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

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