view2 is a subclass of UIViewController. view1 is a subclass of UIView.
开发者_如何学CHow do I launch view1 from view2?
I've tried
[self dismissModalViewControllerAnimated:YES];
and
UIViewControllerhandler.hidden=YES;
For one thing, use better naming. Ff something is a UIViewController subclass, call it myViewController or anything but myView.
To try to answer your question, we need a lot more information, such as where you are trying to do this from, how you showed the views, are you using a UINavigationController
to handle them, etc. From your examples, it seems your view1 (a UIView
) has a UIViewController
subclass called view2
that you want to dismiss to reshow the first view. Ff that's the case then [view2.view removeFromSuperview];
will work.
I would take a look at the User Interface Guide provided by Apple for a better understanding of navigation and view Controllers.
thanx alot its working now and i am not using UINavigationController handler ,I am working on Touch concept in scrollView which is there in my view2 . my working code written in view2(ie:subclass of UIViewController):
(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSSet *allTouches=[event allTouches];
switch ([allTouches count])
{ //for single touch
case 1:{
UITouch *touch [[allTouchesallObjects]objectAtIndex:0];
switch ([touch tapCount])
{ case 1:// action part
//break;
case 2://CODE to return from UIViewContoller to UIView
[self.view removeFromSuperview];
break;
}
}break;
//for double touch
case 2:
{ //action part
}break;
}
}
精彩评论