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

uaecasher

macrumors 65816
Original poster
Jan 29, 2009
1,289
0
Stillwater, OK
Hello,

I've created a button when pressed will show a modal view but the problem now I don't know to to add a button in that view that will remove it and go back to the main view.

Code:
UIView *modalView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
	modalView.opaque = NO;
	modalView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f];
	[self.view addSubview:modalView];

any help? thank you.
 
If you already know how to add a button to perform an action, just do the same thing in the new view.

Plus, technically, what you've done with the code above is not a modal view but just a subview. Modal views are presented and dismissed using UIViewController's presentModalViewController:animated: and dismissModalViewControllerAnimated: instance methods.
 
If you already know how to add a button to perform an action, just do the same thing in the new view.

Plus, technically, what you've done with the code above is not a modal view but just a subview. Modal views are presented and dismissed using UIViewController's presentModalViewController:animated: and dismissModalViewControllerAnimated: instance methods.

okay, I learned how to add action in UIButton, but not sure how to go back to the main view.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.