草庐IT

ViewController-Presenter-Interact

全部标签

iphone - 将委托(delegate)从 ViewController 分离到自己的类

我是iOs开发的新手,我有点困惑我应该如何分离我的代码以避免巨大的ViewController.m文件。目前我的主视图Controller有很多委托(delegate):@interfaceViewController:UIViewController我想减少viewController代码,我想我应该创建单独的类来处理委托(delegate)任务。问题是,如果我为CLLocationManager创建单例类并让它实现委托(delegate)方法,那么我如何与ViewController通信?假设我的CLLocationManager接收到位置更新,我如何告诉viewControlle

ios - 如何在 RAC MVVM 中正确分离 ViewModel 和 ViewController

我刚刚开始更新我的ReactiveCocoa应用程序以使用MVVM模式,并且有几个关于ViewController和ViewModel之间的边界以及ViewController应该有多笨的问题。我要更新的应用程序的第一部分是登录流程,其行为如下。用户输入电子邮件地址、密码并点击登录按钮一个成功的响应包含一个或多个User模型这些User模型与注销按钮一起显示必须在登录View关闭并显示主视图之前为session选择一个用户模型。MVVM之前LoginViewController直接处理LoginButton命令LoginButton命令直接与SessionManager对话LoginV

objective-c - present Modal ViewController 给出黑屏

在警报View方法中,我实现了以下(相当标准的)代码来弹出模态视图:elseif(buttonIndex==1){EmergencyPlanViewController*emergencyPlanView=[[[EmergencyPlanViewControlleralloc]init]autorelease];[emergencyPlanViewsetModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];[selfpresentModalViewController:emergencyPlanViewanimated:Y

ios - 在 iOS 7 上使用 A Person ViewController 重新加载/更改显示的人

我有一个包含ABPersonViewControllersubviewController的类。在iOS7之前,我可以多次传递setDisplayedPerson:消息,更新或替换显示的信息。然而,在iOS7中,一旦viewDidLoad为ABPersonViewControllersubviewController触发,任何对setDisplayedPerson:的后续调用似乎都会被忽略。我可以用另一个替换subviewController,甚至可以为它们之间的过渡设置动画,但这非常不雅。这个有一个开放雷达:rdar://14682982有人看到了吗?编辑:这个问题已经在iOS8be

iphone - 如何关闭多个存在的 Modal ViewController 并返回到根 Tab Bar Controller ?

我有一个在启动时显示presentModalViewController的应用程序。-(BOOL)application:(UIApplication*)applicationdidFinishLaunchingWithOptions:(NSDictionary*)launchOptions{//Overridepointforcustomizationafterapplicationlaunch.//Addthetabbarcontroller'sviewtothewindowanddisplay.[self.windowaddSubview:tabBarController.vie

iphone - 保持 ViewController 处于相同状态/保持它在后台加载?

我目前正在开发一个具有多个View、30多个ViewController的应用程序。我正在使用Storyboard将View流连接在一起。我希望这样,当用户离开一个ViewController时,当他们返回到该View时,它会保持与用户输入的更改相同的状态。(进入UITextFeild、UILabel、UITextView等)因为我有很多View,所以最好不必将信息存储在全局变量中或使用:NSUserDefaults*defaults=[NSUserDefaultsstandardUserDefaults];提前致谢,问候 最佳答案

iphone - 应该从父 ViewController 还是子 ViewController 调用 popViewController?

我可以通过从实例化它的父ViewController调用[self.navigationControllerpopViewControllerAnimated:YES];从UINavigationController的堆栈中弹出一个ViewController,或来自subviewController本身。哪种方式更可取? 最佳答案 我想答案是“最有意义的”;如您所说,您可以从父级、子级或什至其他持有对导航Controller的引用的类中调用popViewControllerAnimated:。对于大多数应用程序,subview将包

iphone - 锁定 ViewController 的方向

我的应用程序支持所有类型的方向,但我希望某些viewController仅支持横向,很少有人锁定Potrait模式。我该怎么做,我试过下面的代码但没有任何效果。-(BOOL)shouldAutorotate{returnNO;}-(NSUInteger)supportedInterfaceOrientations{returnUIInterfaceOrientationMaskPortrait;}//pre-iOS6support-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa

当ViewController移动时,TAB栏和导航栏将不会显示

我需要在一个故事板中移动到另一个ViewController(带有标签栏和导航栏)中的情节提要中有一个ViewController(无标签栏和导航栏)。问题是我能够移至ViewController,但它不会显示标签栏和导航栏。这是我这样做的方式:letstoryboard=UIStoryboard(name:"Main",bundle:nil)letfeedTableViewController=storyboard.instantiateViewController(withIdentifier:"Feed")as!FeedTableViewControllerself.navigation

iphone - 在加载另一个 ViewController 时呈现模态视图 Controller

在用户可以使用我的应用程序之前,他必须先登录。他登录后,数据库就建立好了,因为我需要服务器的信息来建立它。因此,我的根ViewController是LoginViewController,它在成功登录时以模态方式呈现实际应用程序(navigationController堆栈)。如果用户已经在应用程序启动时登录(我将凭据存储在NSUserDefaults中),则LoginViewController应该立即显示该应用程序。因此我重写了方法:-(void)viewDidAppear:(BOOL)animated{[superviewDidAppear:animated];NSInteger