How can I call another viewController through an event?

Joined
Feb 1, 2012
Messages
3
Reaction score
0
Points
1
HELP !!!!

My question is as follows:

I have a ScrollViewer where I programmatically create buttons and add them images. These buttons have the appearance of images created randomly.

To find out which button I clicked, I use:

######################################

for (int i = 1, i <7; i + +)
{
UIButton * button = [[UIButton buttonWithType: UIButtonTypeCustom] retain];
********botao.frame CGRectMake = ((i-1) * 199, 0, 199, 169);
********botao.backgroundColor = [UIColor whiteColor];
********[botao setBackgroundImage: [UIImage imageNamed: [NSString stringWithFormat: @ "image% d.jpg", i]] forState: UIControlStateNormal];

********botao.tag = i;

[botao addTarget:self action:mad: selector(callNextViewController:) forControlEvents: UIControlEventTouchUpInside];

[botao release];
}

######################################


So I call a function by clicking the button:

********[botao addTarget:self action:mad:selector(callNextViewController:) forControlEvents: UIControlEventTouchUpInside];



And then this function is to identify the click and call another view controller:

######################################

# Import "NextViewController.h"

- (IBAction) callNextViewController: (id) sender
{
****UIButton *clicked = (UIButton *) sender;
****NSLog (@"Click in No. %d", clicked.tag);
****
****NextViewController *nextViewController = [[NextViewController alloc] init];
****nextViewController.propTypeInt clicked.tag = / / 1,2,3,4 ...
****[NextViewController setModalTransitionStyle: UIModalTransitionStyleFlipHorizontal];
****[Self presentModalViewController: nextViewController animated: YES];
}

######################################


The problem is that when I run the application and I click on the button, the next view is imported, there is a horizontal flip, and apparently the next view is called. But the screen IS DARK. As none of the objects on the screen is displayed. As if everything had gone.

ALL OBJECTS DISAPPEAR…

I put in some NSLogs "nextViewController" as to whether the "NextViewController" is being called. And it is ok! It works!

The problem is that everything is loaded, but no object is displayed on the screen.

NOTE: I have other calls to the "nextViewController" running through "Segue". But in this case, the buttons are created dynamically, I can not create "Segue" to this.

What can I do to make the objects of "nextViewController" does not disappear when I load the "nextViewController" by the "callNextViewColler"?
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top