我真的很感激在我要去的地方错了任何帮助。基本上我有一个游戏应用程序,我在XCode4(通用) - 我有几个子视图屏幕(.h .m .xib),我需要切换,并在某些情况下重新加载。这里是我正在做它的主AppDelegate.m:可可 - 在切换xibs需要帮助
-(void)switchxibs_nextScreen1 {
//close any views first
[self closesuperviews];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
nextGame *theView = [[nextGame alloc] init];
theView.view.tag=101;
[_window addSubview:theView.view];
}
else
{
nextGame_iPhone *theView = [[nextGame_iPhone alloc] init];
theView.view.tag=101;
[_window addSubview:theView.view];
}
}
-(void) switchxibs_nextScreen2 {
//close any views first
[self closesuperviews];
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
nextGame *theView = [[nextGame2 alloc] init];
theView.view.tag=101;
[_window addSubview:theView.view];
}
else
{
nextGame_iPhone *theView = [[nextGame2_iPhone alloc] init];
theView.view.tag=101;
[_window addSubview:theView.view];
}
}
-(void)closesuperviews{
for (UIView *subview in _window.subviews) {
// Only remove the subviews with tag equal to 101
if(subview.tag==101){
[subview removeFromSuperview];
}
}
}
我不知道这是我应该做的方式。我遇到的问题是,当切换屏幕并返回到一个时,它似乎没有正确关闭。任何帮助将不胜感激。
标签不是唯一的。它对你有帮助吗? –