0

Hey all, I have a Segmented Controller which displays a framed(cgrectmake) UIview containing a UITableView.

I addSubView to display the tableview and this is fine. But inside the tableview in didselect method i want to push a different viewcontroller.

But it fails to appear when i do this, it does register the touch etc. It does display if i addsubview, but i need to really push this view. so to fill the screen rather then the new view only being displayed inside the UIView containing the tableview.

I experimented by pushing the tableview and then pushing the subsequent view, and this final view displayed perfectly, but i need the tableview to be contained in a frame on the screen.

Any suggestions to try?

Michael.

1
  • Apparently the problem extends from the fact im not calling the app delegates navigation controller, must be some other more local one. Nov 8, 2010 at 8:57

2 Answers 2

0

Can you clarify what you've tried maybe with some code? You mentioned your experiment about pushing the tableview and a subsequent view, but views aren't pushed, only viewcontrollers. Just want to make sure that's not what you're trying to do.

You also mentioned it registering for touch...

If things are setup correctly, your tableview is in the view of its own viewController. Make sure that viewController class conforms to UITableViewDelegate. (Or whatever class you decide to set the delegate property to for a UITableView)

i.e. in the myViewControllerClass.h:

@interface myViewControllerClass <UITableViewDelegate>

The class which is your UITableView delegate must also implement the following delegate method:

- (void)tableView:(UITableView *)inTableView didSelectRowAtIndexPath:(NSIndexPath *)inIndexPath

This method will be called upon a row being selected in the tableview. This is where you decide to push another viewController into view onto your first viewController.

3
  • In my viewController containing the UIView tableView, once registering a segmented controller value change, i initialize the target, @interface FavouriteNewsView : UITableViewController, which displays correctly. upon didSelectRow etc.. i call the new view which contains the news article for example i want to display. This is what i want to PushViewController, It displays nothing but the view underneath. But if i addSub view it displays in the UIView its contained in. Nov 7, 2010 at 20:05
  • Would do some proper responses but never asked a question on here, only read..for hours :P the delegate could be something worth trying sadly im not too familier with it, only been developing iphone for 4/5 months. Nov 7, 2010 at 20:06
  • Try rereading the Table View Programming Guide and perhaps look at the sample code: developer.apple.com/library/ios/#documentation/UserExperience/… Nov 7, 2010 at 21:37
0

if you add the tableView as a subview have you remembered to set the delegate to the same object as you're calling didSelectRowAtIndexPath?

You also need to make sure this object is a UITableViewDelegate

2
  • This is the previous example i have that works,- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView deselectRowAtIndexPath:indexPath animated:YES]; newsPageViewController = [[NewsPageViewController alloc] init:indexPath.row:articles]; newsPageViewController.hidesBottomBarWhenPushed = YES; [[self navigationController] pushViewController:newsPageViewController animated:YES]; Nov 7, 2010 at 20:11
  • This example works, pushes the view from the tableview etc, my example is tricky as all this lives inside a constricted UIView initwithframe. but the newPageViewController wants to be pushed, in my current context it wont let me, can only be addSubview, not sure why. Not sure on the delegate thing, that ive wrote below. Nov 7, 2010 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.