presentModalViewController 未呈现新视图
叹气 WWDC 之前的星期五不是问这个问题的好时机,但值得一试。
我创建了一个基于 UIViewController 的项目,从第一个 VC 开始,我尝试通过按钮操作方法加载第二个项目。我执行以下代码:
SaveLocationViewController *saveLocationViewController = [[SaveLocationViewController alloc]
initWithNibName:@"SaveLocationViewController" bundle:nil];
[self presentModalViewController:saveLocationViewController animated:YES];
并且......没有任何可见的事情发生。通过断点,我可以看到 viewDidLoad 和 viewWillAppear 都在 saveLocationViewController 中被调用,因此它正在加载,但视图没有显示。
saveLocationViewController 包含对 initWithNibName 的调用,这是 Apple 样板代码的一部分,但将其删除并没有任何区别。 NIB 似乎是正确的,视图已连接,并且我没有收到任何错误,只是视图不显示。我仍然看到原来的景色。
有任何提示/建议吗?
sigh The Friday before WWDC isn't a good time to be asking this, but it's worth a try.
I created a UIViewController-based project, and from the first VC I'm trying to load a second, via a button action method. I execute the following code:
SaveLocationViewController *saveLocationViewController = [[SaveLocationViewController alloc]
initWithNibName:@"SaveLocationViewController" bundle:nil];
[self presentModalViewController:saveLocationViewController animated:YES];
And... nothing visible happens. Via breakpoints I can see that both viewDidLoad and viewWillAppear are being called in saveLocationViewController, so it is getting loaded, but the view is not being displayed.
saveLocationViewController contains a call to initWithNibName, part of Apple's boilerplate code, but taking it out doesn't make any difference. The NIB appears to be correct, the view is hooked up, and I'm not getting any errors, the view just doesn't display. I still see the original view.
Any hints/suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我看到了你的代码,你给的对象名称与你的类名相同,只是更改了第一个字符 s,所以尽量避免这种类型的命名约定,给出像 saveLocationObject 这样的对象名称或类似的名称。
另外,我希望您看看操作方法是否分配给方法内部的按钮触摸,可能是您忘记分配它,因为就您的代码而言,它没有任何问题。
现在,如果问题仍然存在,那么在这种情况下清理构建,然后尝试一下。
如果问题仍然存在或已解决,请告诉我。
i saw your code and you have given your object name same as your class name with just change in the first character that's s so try to avoid such type of naming conventions, give object names like saveLocationObject or something like that.
Also i would like you to see whether the action method is assigned to the buttons touch up inside method or not may be you have forgot to assign it because as far as your code is concerned its ok doesn't have any problem.
Now if the problem still persists then in that case clean the build and then give it a try.
Do let me know if the issue still remains or is solved.