我想显示UIViewController
MyViewController通过点击UICollectionViewCell
然后关闭它。UIButton的IBAction错误
所以,在我didSelectItemAtIndexPath:
CGRect myFrame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
MyViewController *myController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
myController.view.frame = myFrame;
[self.view addSubview:myController.view];
它的作品!
在MyViewController我有UIButton
链接到:
- (IBAction)close:(id)sender {
[self.view removeFromSuperview];
}
但是当我点击该按钮,我有这个,而不是接近方法调用:
编辑:感谢calampunay and Manohar
问题已解决。但我已经更换两个addSubview和removeFromSuperview到AppDelagate,其中宣布MyViewController作为属性。原因是 - 我想关闭MyViewController即使我会跳转到其他选项卡(我的TabBar在我的应用程序中)或其他东西。
这会更好,如果MyViewController将关闭,即使我在其他地方(不在其框架中)点击。
你的对象被释放,我猜。检查强或保留。 – 2013-04-11 06:45:20
[self.view removeFromSuperview];你的删除..然后扫管笏将被删除..你知道吗? – 2013-04-11 06:57:08