tags:

views:

42

answers:

1

Hi Guys,

newbie in ipad apps here n stucked on a very strange condition.

I have one view based application. In view of Viewcontroller I have added two buttons to draw to shapes. One is cube and one is piramid. Shapes are drawn with openGL code. Both shapes have different view classes.

Now on clicking on the buttons of cube and pyramid respectively, shapes should be drawn into the view of viewController. I am successfully drawing cube shape but cannot draw pyramid shape..!!!

after trying different methods i came to conclusion that "self.view addSubView:tempView" is the problem. This code works fine with cube button , but not with pyramid. Cant fine the exact problem.

here is sample of code

buttons :

cubeButton = [[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(600, -5, 50, 50)];
[cubeButton addTarget:self action:@selector(cubeClicked:) forControlEvents:UIControlEventTouchUpInside];
[cubeButton setBackgroundImage:[UIImage imageNamed:@"square_3D.png"] forState:UIControlStateNormal];

pyramidButton = [[UIButton buttonWithType:UIButtonTypeCustom] initWithFrame:CGRectMake(700, -5, 50, 50)];
[pyramidButton addTarget:self action:@selector(piramidClicked:) forControlEvents:UIControlEventTouchUpInside];
[pyramidButton setBackgroundImage:[UIImage imageNamed:@"triangle_3D.png"] forState:UIControlStateNormal];

methods sample code:

-(IBAction) cubeClicked:(id)sender {
    UIView *cubeView = [[CubeView alloc] initWithFrame:CGRectMake(250, 60, 500, 600)];
    [self.view addSubview:cubeView];
}

-(IBAction) piramidClicked:(id)sender {
    UIView *pyramidView = [[pyramidView alloc] initWithFrame:CGRectMake(250, 60, 500, 600)];
    [self.view pyramidView];
}

Thanks in advance. I appreciate your help guys.

A: 

Is that a typo in your piramidClicked: function? If not, that could be the issue:

-(IBAction)piramidClicked:(id)sender {
    UIView *pyramidView = [[PyramidView alloc] initWithFrame...];
    // this line probably causes a compiler warning ...
    // [self.view pyramidView];
    [self.view addSubview:pyramidView];
}

If it is a typo, I'd check to make sure you made your connections correctly in Interface Builder. Hope that helps.

RJ Regenold
Done!! .....initWithFrame is the only problem.....initWithFrame in PrismView had the error, that's why could not added into the view of viewcontroller.RJ Regenold : Actually I am not using IB...Did everything programmatically. Thank you for replying.
rohan