Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

pgeppl

macrumors newbie
Original poster
Oct 12, 2009
5
0
hi@all
i am new to iphone programming and had a question
i have 1 view controller and there is the automatic created view inside, ok.
all interactions are working well.
so i added a menu and when pressing a button a new view (UIView) which i already created in IB an did the property stuff in .h file too.
now when i press the button on View1(which was automatic created and shown) i want to switch to the other view. but its not working hm
what is the correct order to hide the first view and show the second view?

this does not work:
Code:
[self.view addSubview:MySecondView]; // adding the new view to viewcontroller?
[self.view removeFromSuperview]; // removing first,default view!?
[self.view bringSubviewToFront:MySecondView]; // show the second, manual created, view

BUT it does not work, whats wrong here
maybe someone of you can help me out :)
hopefully
pille
 
http://picfront.de/d/gHtFRKXrOp7/Bildschirmfoto2009-10-12um10.33.13.png

hi again
so what i want to do is as following:
View1 was autocreated with ViewController.xib
so i added View2 manually

all i want now is that when i press button 1 (action is called ok), i want to show View2 instead of View1 and also i want to add some IBActions and IBOutlets to View2!

can you give me an example how this will work?

thanks in advance
pgeppl

p.s.: ...ViewController.h
Code:
	UIView * MyFirstView;
	UIView * MySecondView;	
}

@property (nonatomic,retain) IBOutlet UIView * MySecondView;
@property (nonatomic,retain) IBOutlet UIView * MyFirstView;
 
If you are trying to change the whole screen then I would suggest you use a second view controller and push that onto the navigation stack. If you are trying to change a small part of the visible screen then just add and remove the views from the correct superview.

Either way go back to the start: read all the documentation on Apple's website and actually understand what you are doing. It's very clear you have not done that and are trying to jump ahead without understanding the basics first.
 
you are right
some of the basics i dont understand.
i am new to object-C and the thing with Window, Views is not so really clear but when i read the doc, i tried, my questions are not answered for sure :(

so maybe this is how it works
i create a new project with a view controller.
i add with IB a View1 and a View2 and a navigation bar.
i have to code this in .h file that my project knows the 2 views.
now i can switch between view1 and view2 and how can i resize the views on runtime?

a small coding snippet would help very much ;)

pgeppl
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.