IPhone - After dismissing Modal View Controller - gap is left at top of page

后端 未结 16 847
暖寄归人
暖寄归人 2020-12-24 07:07

When starting the app, if the user doesn\'t have login information stored, I want to display a modal view controller to force the entry of this information. I found through

相关标签:
16条回答
  • 2020-12-24 08:01

    I found a more "elegant" way of doing this. If you add a top view to your window, which is the same size as the window, and add subviews to that top view instead of the window, all subviews will be offset by 20 pixels in the right direction, status bar visibile, no gaps anywhere and even rotation will work correctly. I tested it with iPad and iPhone 4.3 and 5.0... What's the catch? ;)

    0 讨论(0)
  • 2020-12-24 08:01

    You could probably place this code when you dismiss the UIImagePickerController.

    self.view.frame = CGRectMake(0, 0, 320, 480);
    
    0 讨论(0)
  • 2020-12-24 08:03

    OK, I do not know why this happens, it happened to me though and ill tell you how i fixed it. I found that adding a view at 0,0 made it overlap with the status bar...this is weird because before 3.0 I never had projects do this behavior 0,0 was always underneath the status bar. Anyway so I saw that it was overlapping so i started putting my views at 0,20 or however big the status bar is. That was cool until I tried using a modal view controller, when it dismissed i found the gap the size of the status bar (what you are expiriencing), for some reason the modal view thinks 0,0 DOES NOT overlap the status bar and when it dismisses 0,20 (of your previous view) shows up as if (0,0) does not over lap and (0,20) has the extra white gap. Why did this start happening ? No clue. Anyway to fix it i knew i had to fix the whole overlap of the view and status bar at 0,0 thing. I kept trying but nothing, then I decided to try to create a new View based project in xcode (which sets up the initial view for you) and see if their view overlaps (or if they put it at 0,20), what i found is that it DID NOT overlap and 0,0 was the right placing, right below the status bar and not overlapping it. Bizzare? i think so. So what i did on my project was copy the set up they had in the newly created view based project (they set the viewControllers property through Interface Builder, you can create a view based project like I did and just mimic their set up), i found that this fixed the issue, views at 0,0 no longer overlapped the status bar and dismissing modal view controllers no longer left the gap. Dont know if this is your case, but it might be, hopefully this will help you.

    0 讨论(0)
  • 2020-12-24 08:03

    I've run into this a few times and did the workaround (re-setting the frame) because of time pressure, but the last time I ran into it I found a real fix. Instead of creating your top level view controller in code (if it is), try having it be created in the UIWindow and IBOutlet it to the AppDelegate instead.

    Worked for me.

    0 讨论(0)
提交回复
热议问题