|Nov 3, 2008, 09:30 AM||#1|
Question on view controllers and program design
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.
|Nov 3, 2008, 10:07 AM||#2|
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.
|Nov 3, 2008, 11:07 AM||#3|
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.
|Nov 3, 2008, 11:31 AM||#4|
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.
|Thread Tools||Search this Thread|
|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 11:49 AM|
|Xcode doesn't make View Controllers by default anymore||gwelmarten||Mac Programming||3||Feb 20, 2013 04:14 PM|
|Auto Layout and Hiding Embedded View Controllers||isthisonetaken||iPhone/iPad Programming||2||Dec 9, 2012 04:47 PM|
|Views & view controllers - what is the correct way to structure?||MickeyT||iPhone/iPad Programming||11||Aug 8, 2012 07:29 PM|
|Passing Data between View Controllers : from uitableview to a details view controller||EliasRahme||iPhone/iPad Programming||7||Jul 20, 2012 09:04 AM|
All times are GMT -5. The time now is 07:19 AM.