我正在加载一个从webservices获取数据的视图。因此,根据来自服务器的响应代码,如果响应代码为400,我将显示当前视图或重定向到另一个视图( ErrorView )。但是,我不会被重定向到ErrorView并在控制台"Attempt to present <ErrorView: 0xe332f30> on ViewController while a presentation is in progress!"中找到消息
在谷歌出来后,我发现在放置整个代码后,将vieDidLoad代码放置到viewDidAppear,它重定向到错误视图,并在ios7中为状态栏问题工作correctly.But我使用了代码
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if(responsecode==200)
{
//load current view
}
else
{
//Load anotherview(ErrorView)
}
float systemVersion=[[[UIDevice currentDevice] systemVersion] floatValue];
if(systemVersion>=7.0f)
{
CGRect tempRect;
for(UIView *sub in [[self view] subviews])
{
tempRect = [sub frame];
tempRect.origin.y += 20.0f;
[sub setFrame:tempRect];
}
}
}首先状态栏出现在顶部,然后加载整个视图数据后,视图得到调整和status bar dropsdown by 20px,看起来像odd.Can我得到它自动调整之前视图加载完成?
任何想法/建议都是值得欣赏的。
发布于 2013-12-23 15:30:42
我认为,你应该把这段代码分开
-(void)viewDidLoad
{
float systemVersion=[[[UIDevice currentDevice] systemVersion] floatValue];
if(systemVersion>=7.0f)
{
CGRect tempRect;
for(UIView *sub in [[self view] subviews])
{
tempRect = [sub frame];
tempRect.origin.y += 20.0f;
[sub setFrame:tempRect];
}
}
}
-(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
if(responsecode==200)
{
//load current view
}
else
{
//Load anotherview(ErrorView)
}
}https://stackoverflow.com/questions/20738775
复制相似问题