0

I have created a custom cell with buttons. the buttons should present a modalViewController, one for the email and another for a webView. I have also created a delegate to get a callback from the class.

so in the cell class:

 _delegateAction = [[HistoryVC alloc] init];
    _delegateAction.delegate = self; 
    [_delegateAction openData:_data Type:_title.text]; //start process

The class that the table is on is a UIviewController that have a table view. the (with the custome cells that are another class inherit from UiTableViewCell.

if you need meed information just tell me.

in the UIviewController I am trying to present a modal view as follow:

-(void) openData: (NSString *)data Type:(NSString*)type
{
    QRWebView * webView = [[QRWebView alloc] init];
    webView.url = data;
    [self presentModalViewController: webView animated:YES];
}

The modalview doesn't show. I know that I'm doing something wrong, but what is it?

Thanks in advance.

NDM
  • 944
  • 9
  • 30

2 Answers2

0

You have created a new view controller with _delegateAction = [[HistoryVC alloc] init]; but you haven't made it part of the controller hierarchy by presenting it in any way.

When you call [self presentModalViewController: webView animated:YES];, your self is the new controller and, since it's not in the hierarchy, it's not capable of presenting another controller.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57
  • I assume you know which view controller is handling the display at the time you want to switch to the `QRWebView`. Have **that one** call `presentModalViewController`. – Phillip Mills Jun 01 '12 at 11:27
  • I thought it self, but self doesn't do anything. I am new to xcode, and as far as I understood the self is the one that presenting the view. Please help – NDM Jun 02 '12 at 06:31
  • For any code you write, `self` is an object of the class that the code is in. So, in what you posted, `self` is a `HistoryVC` object. The problem is that it's a new one you just created. You need a reference to a UIViewController that's already in control of the screen...whichever one contains your table view. – Phillip Mills Jun 02 '12 at 11:59
  • How can I use it as a reference? I am sorry I am confused. – NDM Jun 02 '12 at 18:59
  • Please, I have no clue how to perform that, would it help to present all the class? – NDM Jun 03 '12 at 04:55
  • _delegateAction = [[HistoryVC alloc] init]; _delegateAction.delegate = self; [_delegateAction openData:_data Type:_title.text]; //start process The code above is placed on a TableviewCell and not on a uiviewController, how can I make it in the hierarchy? – NDM Jun 03 '12 at 11:09
0

I have managed to fix it by implementing the PresentModalView.

What I did is to create a showModal and DismissModal in the AppDelegate class.

Those method add to the Window the view I wanted by adding it as:

[Window addsubview TheView];

and for the Dismiss is removeFromSuperview.

I implemented an animation to fake the modalView animation.

to get to those methods I have used the shareApplication.

and it's works.

NDM
  • 944
  • 9
  • 30