How to push UIViewController into UINavigationController from seperate UIView of different UIViewController which uses this view

I have a UIViewController (AbcViewController) with NavigationController. AbcViewController uses UIView (AbcView) as its view. AbcView has a UITableView. I have set this TableView's datasource in AbcViewController and delegate in its SuperView i.e. AbcView. How will I push another UIViewController (XyzViewcontroller) into navigationController when I select a row in this table because it gives

"error: request for member 'navigationController' in something not a structure or union"

when I do this:

[self.navigationController pushViewController:xyzViewcontroller animated:TRUE]; 

I also did this:

AbcViewController *parentVC;
[parentVC.navigationController pushViewController:xyzViewcontroller animated:TRUE]; 

Though it builds successfully, XyzViewcontroller's view does not appear. It does not push XyzViewcontroller's view onto navigationController.

Answers


We can make a delegate on AbcView so that we can refer back to the view's viewController which in this case is AbcViewController. We can set delegate as:

@interface AbcView : UIView

{ 
    id delegate;
}

@property(nonatomic, assign) id delegate;

Then in AbcViewController, set the view's delegate like this:

[abcView setDelegate:self];

Now in table method using our delegate from within AbcView as:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   [delegate pushOtherView];

}

it will call - (void)pushOtherView method in AbcViewController whose definition is:

- (void)pushOtherView 
{   
    XyzViewcontroller * xyzViewcontroller = [[[XyzViewcontroller alloc] init] autorelease];
   [self.navigationController pushViewController:xyzViewcontroller animated:YES];   
}

But before using this method, it should be mentioned in protocols otherwise it will show

Warniing:

-pushOtherView' not found in protocol(s).


Need Your Help

Creating custom module in Vtiger CRM from scratch with table

php vtiger

I am new to Vtiger CRM and I have searched a lot to find how to create a custom module in Vtiger CRM with a table associated with it from scratch. I am not able to follow the documentation provided...