|Oct 20, 2009, 01: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, 11: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, 08: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|
|MagnetBall - 60 brain-boggling levels, built-in level editor, completely free!||BubbaMonkey||Mac Applications and Mac App Store||0||Aug 25, 2011 09:16 PM|
|High level historical benchmarks of Power Macs||rafacq||PowerPC Macs||5||Aug 22, 2008 09:23 AM|
|What are the 5 high level programming languages||Eric Lewis||Community Discussion||11||Oct 10, 2007 12:25 PM|
|High level video card in iMac???||toomuchstereo||iMac||35||Mar 29, 2007 01:47 PM|
|NEEDED!! High level OS X Systems Administrator to work on a Feature CG Film near S.F.||critterPix||Community||8||Feb 15, 2005 12:35 AM|
All times are GMT -5. The time now is 09:05 AM.