||Thread Tools||Search this Thread||Display Modes|
|Oct 20, 2009, 12:31 AM||#1|
UITabBar - Need high level explanation
Okay, so I'm new to Objective C, Xcode, and thus also the iPhone SDK
However I'm not to new programming or OO thinking, so feel free to explain things in terms of regular SE ideas.
So I've written my first little app. I use a UITabBar to flip between two screens, the main functionality of the app, and a page of preferences.
Everything has worked fine, and I'm starting to get a hang of things, but here is where my understanding of what is actually going on all breaks down.
On the preferences page is a button, that when pressed needs to change a label on the the first page. I have an event that captures the button press just fine, but when it goes to change the label the program crashes. I'm not great with debugging things in Xcode yet, but if I had to hazard a guess, I'd say it was some sort of scope problem?
I'm 99.99% sure I have everything connected properly in IB, as I am fully able to create a button in a tab that modifies a label within the currently selected tab. It's modifying a tab that isn't currently being viewed that has me stuck.
When a UITabBar is used, does only one "tab" exist at a time? This might explain it.
My second thought was "I'll just store the preference state in a few variables, and upon loading the first tab, use those variables to modify the UI!". However I can't find any sort of "on tab load" event.
I've searched high and low for an answer, and now I'm "giving up" and coming to you guys for help. It's always the worst when you can't find an answer to a seemingly simple problem, because that usually means it's stupid-simple.
Current: MacMini 2ghz / iPod Touch 2g / iPhone 4g
Retired: Alum Powerbook 1.25ghz / 4gb iPod Mini
"ooo! They have the internet on computers now!" - Homer J. Simpson
|Oct 20, 2009, 10:34 AM||#2|
There's a bunch of different ways you could communicate that information from one to the other. Set variables on the shared application delegate and use those to reference them and send messages to each other. If you're using a tabBarController it has an array of the viewControllers it's managing, have one view register for a notification and the other post the notification when it gets the event. Set up key-value observing on a global variable so when viewController in tab 2 changes the value viewController in tab 1 detects it, etc.
|Oct 20, 2009, 07:13 PM||#3|
Ok first of all, are you correctly using the IBAction? Second, did you connect the two views in Interface builder? If both of those are correct in both code and interface builder, you need to assign the label you are changing as a property. Doing this is simple. In the view with the label header file at the bottom but before @end, put this:
@property(nonatomic, retain) UILabel *YourLabelName;
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|21.5 entry level vs. 21.5 high end late 2013||Escritor||iMac||2||Nov 26, 2013 04:14 AM|
|[iPhone] Bubble Level - Elegant and accurate level app - FREE - out today!||Phoenix Mobile||iPhone and iPod touch Apps||1||Mar 26, 2013 11:21 PM|
|Math, physics and chemistry on high level||Paludan||iPad Tips, Help and Troubleshooting||1||Jan 10, 2013 01:09 PM|
|Mid Level Mac Mini outperform base Level Imac 21.5 (2011)||tears2040||Mac mini||9||Oct 26, 2012 05:27 AM|
|High Level TECH TALK - Printers||chefwong||Mac Peripherals||0||Sep 22, 2012 05:22 PM|
All times are GMT -5. The time now is 06:04 PM.