如何在分屏中刷新iPad屏幕左侧视图? [英] How to refresh iPad screen left side view in split screen?

查看:910
本文介绍了如何在分屏中刷新iPad屏幕左侧视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个iPad视图,它被分成两个视图,所以我需要从右侧视图刷新api响应成功的左侧视图。但左侧视图代码在swift中的目标c和右侧视图代码中。所以我如何刷新左侧视图。
我在swift类中创建了委托

I had an iPad view which is splited into two views so i need to refresh left side view on the success of api response from right side view. But left side view code is in objective c and right side view code in swift.So how i can refresh the left side view. I ahve created the delegate in swift class

  @objc protocol RefreshDelegate {
       func RefreshAfterSuccess()
  }
  class UpgradeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, UIPickerViewDataSource, UIPickerViewDelegate{

var delegate:RefreshDelegate?
}

现在,当我无法在Objective-c类中导入此委托时,不能在我的objective-c类中实现RefreshAfterSuccess方法。

Now when i am not able import this delegate in Objective-c class and cannot implement RefreshAfterSuccess method in my objective-c class.

推荐答案

方法1:

所以我的理解是你的右视图是类型为UpgradeViewController的快速视图。

So my understanding is that your right view is the swift one of type UpgradeViewController.

然后在你的类定义中为objective-c中的左边

Then in your class definition for the left one that is in objective-c

1)首先,您必须声明它在头文件的<>括号中实现此协议(也可以在实现中执行,但不需要隐藏它这里),并且还添加了所需的方法声明

1) First you have to declare that it is implementing this protocol in <> brackets in the header file (could also do in the implementation, but no need to hide it here), and also add the required method declaration

@interface LeftViewController : UIViewController <RefreshDelegate>

-(void)refreshAfterSucces;

@end

2)然后添加方法的实际实现.m文件

2) Then add the actual implementation of the method in the .m file

@implementation

-(void)refreshAfterSucces {
    // Do your refreshing stuff here
}

@end

3 )当你添加它们时,请不要忘记将右视图控制器的.delegate属性设置为指向左视图控制器对象。

3) DON'T FORGET to set your right view controller's .delegate property to point to the left view controller object as you're adding them.

方法2:

如果这些是嵌套在UISplitViewController中的两个UIViewController子类,那么每个子类都应该有一个指向包含它们的UISplitViewController的.splitViewController属性。
UISplitViewController本身应该有一个属性.viewControllers,它是一个包含所有子视图控制器的数组,所以从右边的VC你应该可以访问左边的那个(如果使用objc)

If these are two UIViewController subclasses nested in a UISplitViewController, then then each of them should have a .splitViewController property pointing to the UISplitViewController containing them. The UISplitViewController itself should have a property .viewControllers that is an array with all of its child view controllers so from the right VC you should be able to access the left one (if using objc)

self.splitViewController.viewControllers[0]

然后调用它上面的方法等

then call methods on it, etc

这篇关于如何在分屏中刷新iPad屏幕左侧视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆