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

Thread Tools Search this Thread Display Modes
Old Nov 3, 2008, 08:30 AM   #1
macrumors newbie
Join Date: Nov 2008
Question on view controllers and program design

Hello everyone:
I'm sure someone has come across this at one time or another and hopefully can help.

I have a UITableView for which I have created a custom view for each row. The custom view is created in another class (which implements a UIView) which includes two images, a label, and a detaildisclosurebutton.

The view displays just fine, the problem I have run into comes in when the user pushes the detaildisclosurebutton. The program should push another view controller onto the view controller stack then display it.

I'm having a hard time trying to do this because since the button is created in the seperate view class, the button push is also handled there and I either cannot push the new view controller onto the view controller stack (because it implements a UIView and not a UIViewController) or there's some way of doing it that I'm not aware of. It would seem that no matter what you do, you need a reference to the rootviewcontroller which seems like it would end up being a cyclical reference.

Should I add a reference to the rootviewcontroller in the custom UIView class and push it that way? (which seems a little messy) Or is there a better way of doing something like this? I can see that this issue can come up in the future and I would like to get the accepted method for doing this.

JJS123 is offline   0 Reply With Quote
Old Nov 3, 2008, 09:07 AM   #2
macrumors member
Join Date: Jul 2008
There is a class called UITableViewCell, which is exactly what you need. Make your custom view for each row inherit from UITableViewCell and you should get notification whenever user taps on the row. The best way to evaluate this is to implement UITableViewDelegate method:
I hope this helps.
lawicko is offline   0 Reply With Quote
Old Nov 3, 2008, 10:07 AM   #3
macrumors 68030
PhoneyDeveloper's Avatar
Join Date: Sep 2008
If you have a tableview then you have a view controller that controls it. All the code for navigation to new views should be in that view controller. It should have a didSelectRowAtIndexPath, which is called when a row is touched. If there's some other control in your cells that get touched they should send their action method to this view controller.

The next view that gets pushed should have its own view controller.
PhoneyDeveloper is offline   0 Reply With Quote
Old Nov 3, 2008, 10:31 AM   #4
Thread Starter
macrumors newbie
Join Date: Nov 2008

So then if someone pushes a button in that view, I should be able to respond to that event in my UIView class, and pass the event along to the next level up the chain of responders? I think that would probably be the table row itself (didSelectRowAtIndexPath I guess)

If that's what you're saying, then that's something I need to do a little research on.

If I can pass the event to the table row, then I have to figure out what was touched in the tablerow. But at least this would put me back into the roowviewcontroller class which is where I need to be to push the new view controller.

I'm still green enough that I do not yet understand how to find out what was touched or pushed in the view, nor am I familliar with sending the event up the chain of responders, but I'm sure Apple has something with regard to that.

JJS123 is offline   0 Reply With Quote

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
How do I program my app to go to the last view controller the user was on? moonman239 iPhone/iPad Programming 11 Feb 21, 2014 10:49 AM
Xcode doesn't make View Controllers by default anymore gwelmarten Mac Programming 3 Feb 20, 2013 03:14 PM
Auto Layout and Hiding Embedded View Controllers isthisonetaken iPhone/iPad Programming 2 Dec 9, 2012 03:47 PM
Views & view controllers - what is the correct way to structure? MickeyT iPhone/iPad Programming 11 Aug 8, 2012 06:29 PM
Passing Data between View Controllers : from uitableview to a details view controller EliasRahme iPhone/iPad Programming 7 Jul 20, 2012 08:04 AM

Forum Jump

All times are GMT -5. The time now is 09:01 PM.

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

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