views:

217

answers:

4

Hi guys, so im having a UIViewController view with a UITableView. So the UIViewController class name is SelectionScreen. The UITableView class name is SelectionScreenTable.

Picture: http://img717.imageshack.us/i/screenshot20100609atpm0.png/

I have declared a UITableView *selectionTable in SelectionScreen class and connected it to the xib file of the SelectionScreen

what the problem is , is that when i click a row in the table,it stays selected as highlighted blue, it calls the didSelectRowAtIndexPath (checked with NSLog) but not pushing a new view which is called(GraphView).

This is the code which i use to call the new controller WHICH WORKS with a normal button

GraphView *aSelectionScreenViewController = [[GraphView alloc]
         initWithNibName:@"GraphView"
         bundle:nil];

[self presentModalViewController:aSelectionScreenViewController animated: YES]; [aSelectionScreenViewController release];

I searched around and found that I need to set a delegate for the table in the UITableView class itself on the viewload

tableview.delegate = self;

or

self.tableview.delegate = self;

But it was not working. the controller was still not being pushed, and yes i have checked the controller is not nil as i tried it with a simple button.

So i was thinking whether i should set the delegate of the UITableView at the UIViewController instead, so i tried this code

selectionTable.delegate = selectionTable.self;

but obviously it did not work =\, it messed up the whole UITableView and caused all the cells to be its predefined settings.

So does anybody have any idea on how i can get it to work.

A: 

It's a bit hard to get the full picture here, but I can try some hints.

The outlets seem to be correctly connected from the screenshot, although Selection Screen Table could probably be called Selection Screen Table Controller and the class name should be SelectionScreenTableController for less confusion.

I think the problem could be that the method presentModalViewController: must be called on an active view controller to work.

From what I can tell you have three view controllers, a SelectionScreenTableController, a GraphViewController, and then there must also be some kind of main controller, probably SelectionScreenController.

The SelectionScreenController is the active view controller, so that must be the one to have sent the presentModalViewController: message.

There are several ways you could solve this. The quick fix would be to make an outlet in SelectionScreenTableController called selectionScreenController and link it to File's Owner in the nib file (assuming your SelectionScreen class is in fact a view controller), then call:

[selectionScreenController
    presentModalViewController:aSelectionScreenViewController
    animated: YES];

instead in your current listing of didSelectRowAtIndexPath:

Hi! thanks for answering! i tried ur code and now it looks like this GraphView *aSelectionScreenViewController = [[GraphView alloc] initWithNibName:@"GraphView" bundle:nil];[selectionScreenController presentModalViewController:aSelectionScreenViewController animated: YES];No idea whether its what your talking about but its not working, :( forgive me if im doing anything wrong. Here are some sshots to show the xib connectionshttp://img10.imageshack.us/i/screenshot20100609atpm0.png/http://img268.imageshack.us/i/screenshot20100609atpm0.png/
Kenneth
http://img268.imageshack.us/i/screenshot20100609atpm0.png/
Kenneth
Hm, but now you seem to have moved the outlets and changed the class assignments from the first post.The outlets seemed fine before, but now you say file's owner should be of class SelectionScreenTable and that the table view controller should be of class SelectionScreen, and you can't just switch those around like that.If you want to try what I ment to explain, you have to move the classes and outlets back to the way it was, then in your SelectionScreenTable class add an outlet:@property (nonatomic, retain) IBOutlet SelectionScreen *selectionScreen;(not enough room)
However, I'm not sure how you want things to look in the app itself, if you mean for the selection screen to only hold the table, then get rid of the SelectionScreenTable orange thingy in your nib altogether and make File's Owner of class SelectionScreenTable instead. Then put all your code in SelectionScreenTable.m instead of spreading it between SelectionScreen.m and SelectionScreenTable.m
hmm actually i want the SelectionScreen to hold the selectionScreenTable, then on clicking a row, it will push a view called graphView that sorts of overlaps the whole selectionScreen.
Kenneth
A: 

Hey guys, i solved it, in the screenshot

http://img717.imageshack.us/i/screenshot20100609atpm0.png/

The SelectionScreenTable controller in the XIB of SelectionScreen, the view outlet was not connected to the XIB in the SelectionScreen XIB, so i guess it wasn't properly configured.

Kenneth
A: 

Hmm actually i have another problem now, the view is not being presented properly In this first 'drawing' i have a view that has a UItableView http://img814.imageshack.us/i/sshot1u.png/

But once i click a UITableViewcell, the graphview is being presented in this way :\ (screenshot below at comment)

im using this code [self presentModalViewController:viewController animated:YES]

instead of the normal standard code for didRowSelectAtIndexpath which is not working....

[[self navigationController] pushViewController:viewController animated:Yes];

any idea guys?

Kenneth
http://img819.imageshack.us/i/sshot2.png/
Kenneth
i think i should set a method in SelectionScreen instead to call graphView when the didRowCellatIndex in SelectionScreenTable . but any idea on how the code would be like?im still a newb in iphone programming
Kenneth
HMM i found a real interesting problem, if i comment OFF the - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation in selectionscreen , everything messes up but i am able to see the whole graphView screen ._.i guess ima sort things out with the orientations, but if any1 has any guides for me to follow, would be great
Kenneth
****UPDATE*****i found out that it was the UITableView's problem, on the surface is seems like it is in landscape mode, but when i click on a row, it turns to portrait mode for an instant. then brings out the new view from the left. argh, im going crazy here.
Kenneth
Note-SelectionScreen(UIViewController) is holding SelectionScreenTable(UITableView)when SelectionScreenTable didrowSelect is being called, etc a cell is clicked.i want another UIViewController called GraphView to overlap SelectionScreen.
Kenneth
Im thinking that in that instant when i click on a cell, the tableview turns back to portrait mode and then calls graphView, but however i already set the UIOrientation to landscapeleft,right only
Kenneth
hmm i searched around and found that some guys too had similar problems like when in the view is in landscape, and calling out the other sorts of get called in the wrong orientation in the wrong direction.
Kenneth
A: 

Hey guys its me again.

i solved it instead of using presentModalViewController.

i used an animation to bring in the view instead More info in the link below http://www.iphonedevsdk.com/forum/iphone-sdk-development/13427-uiview-slide-transition.html

Kenneth