Iphone presentModalViewController

I have an application inside which is UIViewController

attached to UIWindow

. seemingly UIViewController

, I added a button and a 100x80 uiview_1. This uiview_1 contains another uiview_2 as a subview of the same size and contains the uiview_2 UIImageView

or UIlable

at runtime (both UIImageView

and UIlable

included userinteraction

)

now when I press / UIImageView

, I want to show the new view with presentModalViewController

, the problem is the view is shown, and with the back button on the navigation bar, I go to the previous / home screen. here the problem occurs in the picture, now I cannot touch the button or the UIImageView. both don't respond, but the app doesn't crash or freeze.

What's bad about it?

Plz help this ...

----- EDIT :

First approach:

SWVController *swvController = [[SWVController alloc] init];
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController];
UIViewController *pushController = [[UIViewController alloc] init];
UIWindow *win = [[UIApplication sharedApplication] keyWindow];
[win addSubview:pushController.view];
[pushController presentModalViewController:viewNavController animated:YES];

      

In swvController, I have a back button that calls the cancelModelViewController function on click -> result is main screen. ctrls do not respond to touch-sandy 3 hours ago.

Second approach:

SWVController *swvController = [[SWVController alloc] init];
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController];
UIViewController *pushController = [[UIViewController alloc] init];
[self addSubview:pushController.view];
[pushController presentModalViewController:viewNavController animated:YES];

      

In swvController I have a back button that calls cancelModelViewController function on click -> result: swvController back button on navbar not responding - sandy 3 hours ago

Third approach:

SWVController *swvController = [[SWVController alloc] init];
UINavigationController *viewNavController = [[UINavigationController alloc] initWithRootViewController:swvController];
SampleAppAppDelegate *appdel = [[UIApplication sharedApplication] delegate]; [appdel.viewController presentModalViewController:viewNavController animated:YES];

      

-> the result works fine, but the problem is I don't want to use SampleAppAppDelegate, I want to give my little Uiview (100x80) as a ctrl to another person where my ctrl won't be able to get the AppDelegate of thet application at runtime. - sandy 3 hours ago

+2


source to share


2 answers


Calling this method when you want to present a modal view controller:

- (IBAction)showInfo {    
    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
    controller.delegate = self;

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:controller animated:YES];

    [controller release];
}

      

Add this method to yourself:

- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
    [self dismissModalViewControllerAnimated:YES];
}

      



Use a toolbar or other button and wire it to this method in your modular controller:

- (IBAction)done {
    [self.delegate flipsideViewControllerDidFinish:self];   
}

      

All code comes from Apple.

+4


source


How did you handle the click / touch UIImageView

? TouchesBegan / Out?

Try putting some logs ( NSLog

) and run your app in debug mode (put some breakpoints) to see if control has reached your action ...



Plus, when you do presentModalViewController

, you don't need to exit using the back button on the navigation bar ... you only need dismissModelViewController

to hide it.

0


source







All Articles