首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >viewdidLoad/ viewDidAppear问题

viewdidLoad/ viewDidAppear问题
EN

Stack Overflow用户
提问于 2013-12-23 15:20:16
回答 1查看 72关注 0票数 0

我正在加载一个从webservices获取数据的视图。因此,根据来自服务器的响应代码,如果响应代码为400,我将显示当前视图或重定向到另一个视图( ErrorView )。但是,我不会被重定向到ErrorView并在控制台"Attempt to present <ErrorView: 0xe332f30> on ViewController while a presentation is in progress!"中找到消息

在谷歌出来后,我发现在放置整个代码后,将vieDidLoad代码放置到viewDidAppear,它重定向到错误视图,并在ios7中为状态栏问题工作correctly.But我使用了代码

代码语言:javascript
复制
-(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我得到它自动调整之前视图加载完成?

任何想法/建议都是值得欣赏的。

EN

回答 1

Stack Overflow用户

发布于 2013-12-23 15:30:42

我认为,你应该把这段代码分开

代码语言:javascript
复制
-(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)
   }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20738775

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档