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 Nov 7, 2008, 12:31 PM   #1
Lakario
macrumors member
 
Join Date: Oct 2008
Modify Items in a UIToolbar

I have a UIToolbar that I want to add/remove buttons from based on context, but looking at the class definition the UIToolbar uses a static NSArray for it's item collection. Short of overwriting the whole items array with another array is there any way to add or remove buttons at run time?
Lakario is offline   0 Reply With Quote
Old Nov 7, 2008, 12:36 PM   #2
italiano40
macrumors 65816
 
italiano40's Avatar
 
Join Date: Oct 2007
Location: NY
Send a message via AIM to italiano40 Send a message via Skype™ to italiano40
you can rename the buttons and based on the name of the button i would then run the method or action during run time
__________________
Macbook 1gb Ram 2.10ghz 120gb HD Leopard
iphone 3g 8gb
Xbox360(Italiano40)
twitter
italiano40 is offline   0 Reply With Quote
Old Nov 7, 2008, 01:03 PM   #3
Lakario
Thread Starter
macrumors member
 
Join Date: Oct 2008
Quote:
Originally Posted by italiano40 View Post
you can rename the buttons and based on the name of the button i would then run the method or action during run time
What about enabling or disabling a button altogether? I don't see anything to that effect in the UIBarButtonItem class reference.
Lakario is offline   0 Reply With Quote
Old Nov 7, 2008, 01:16 PM   #4
Lakario
Thread Starter
macrumors member
 
Join Date: Oct 2008
Alternatively, I could keep an NSMutableArray local to the view that contains the items I want to display on the bar and then call setItems on the Toolbar with the modified items array. Would that be better than trying to tweak the items in the static array?
Lakario is offline   0 Reply With Quote
Old Nov 7, 2008, 10:35 PM   #5
PhoneyDeveloper
macrumors 68030
 
PhoneyDeveloper's Avatar
 
Join Date: Sep 2008
You can keep two arrays and swap them. You can put the same buttons in both arrays, except for those that are different. It's easy, works fine.

I build one in IB. Then in viewDidLoad I build the second one using the buttons from the first one that I want to reuse.
PhoneyDeveloper 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
iPhone: Folderenhancer: modify layout? fridayxiii Jailbreaks and iOS Hacks 2 Feb 20, 2013 02:06 PM
iPhone: BiteSMS - how do I modify notifications? hakr100 Jailbreaks and iOS Hacks 4 Feb 17, 2013 09:35 AM
iPhone: who to modify ? Zaino Jailbreaks and iOS Hacks 5 Feb 9, 2013 09:55 AM
Not all items being tagged when tagging multiple items in iTunes willryan42 Mac Applications and Mac App Store 0 Oct 8, 2012 06:44 PM
UISlider in UIToolbar -> can't get slider.value and process it. iOS SDK. gwelmarten iPhone/iPad Programming 11 Jul 10, 2012 09:18 AM

Forum Jump

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

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

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