草庐IT

delegations

全部标签

ios - Objective-C 接口(interface)、委托(delegate)和协议(protocol)

因此,我正在努力思考Objective-C接口(interface)、委托(delegate)和协议(protocol)。所以我有一个问题:委托(delegate)必须在单独的文件中还是可以是类中定义的方法?协议(protocol)是否类似于java接口(interface)?这是我目前的理解方式,如果你使用这个协议(protocol),它基本上会让你实现方法。我仍然对接口(interface)感到困惑。我很确定它们与java中的接口(interface)没有任何相似之处。也许这只是将在类中实现的变量声明。 最佳答案 委托(dele

ios - 未调用 UIPageViewController 委托(delegate)方法

在我的应用程序中,我有一个RootViewController(UIPageViewController)、一个FirstController(UIViewController)和一个SecondController(UIViewController)。两个UIViewController中的两个View在RootViewController上滚动。在我的RootViewController.h中:@interfaceRootController:UIPageViewController但是当我在不同的View之间滚动时,委托(delegate)方法如下:-(void)pageView

iphone - CLLocationManager 从不调用委托(delegate)方法

这个问题在这里已经有了答案:WhytheCLLocationManagerdelegateisnotgettingcallediniPhoneSDK4.0?(5个答案)关闭7年前。您好,我在iPhone上玩弄位置,从一开始我就遇到了问题。我已经定位了我的问题并确定是CLLocationManager困扰着我。所以我开发了非常简单的应用程序。我只有一个带有CLLocationManager的ViewController。在View加载时,我初始化了CLLocationManager并开始更新。我还实现了两种方法didFailWithError和didUpdateToLocation。我已

ios - 加载委托(delegate)时警告窗口层次结构

今天我更新了我的Xcode,并开始为新的iPhone5屏幕更新我的应用程序。我突然注意到,每次从屏幕A转到屏幕B时,我都会收到此警告:Warning:Attempttopresentonwhoseviewisnotinthewindowhierarchy!//ThisdelegatemethodpreparestheseguefromScreenA(DilemmaViewController)toScreenB(OptionsViewController)-(void)prepareForSegue:(UIStoryboardSegue*)seguesender:(id)sender{

ios - 无法配置数据源和委托(delegate)

所以我将Xcode和GitHub项目代码升级到swift3.0(我的项目在ObjC中,我从GitHub使用的一些pod在Swift中)。我遇到了一堆错误,现在我被困在这些错误上了。出于某种原因,我的数据源和floatingActionButton(githere)的委托(delegate)现在不起作用。我尝试以编程方式和Storyboard上设置dataSource和delegate,但没有成功。错误:Property'dataSource'notfoundonobjectoftype'LiquidFloatingActionButton*'Property'delegate'notf

ios - 正确访问 segue 的目标 View Controller 以分配协议(protocol)委托(delegate)

在实现选择列表时,我在集成segue和协议(protocol)时遇到了一些问题。在我的选择列表.h中我有:#import@protocolSelectionListViewControllerDelegate@required-(void)rowChosen:(NSInteger)row;@end@interfaceSelectColor:UITableViewController-(IBAction)saveSelectedColor;@property(nonatomic,strong)iddelegate;@end在我的选择列表.m中,我有:@implementationSele

c# - Xamarin 表单 DisplayAlert 在从委托(delegate)调用的函数调用时不显示

当我从size函数内部调用Greet时,DisplayAlert会按预期显示警报但是,当在事件发生后从委托(delegate)中调用它时,它将使用正确的名称(GreetHasbeenCalled)记录到输出,但DisplayAlert不会节目。publicclassCustomPage:ContentPage{...protectedoverridevoidOnValidSizeAllocated(doublewidth,doubleheight){...Greet("Test");app.FB.GetName();app.FB.NameRecieved+=(s,e)=>{Greet(

IOS:两个tableview的tableview委托(delegate)方法

我在一个类中有一个TableView的委托(delegate)方法:-(NSInteger)numberOfSectionsInTableView:(UITableView*)tableView{return1;}-(NSInteger)tableView:(UITableView*)tableViewnumberOfRowsInSection:(NSInteger)section{return[array1count];}-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndex

iphone - 将在 Interface Builder 中创建的 UITabBarController 设置为委托(delegate)

我使用TabBar模板创建了我的iOS应用程序,所以这里是带有条形按钮的UITabBarController。一个问题是如何将其设置为委托(delegate)。我在SO发现它必须在AppDelegate中以编程方式设置,但我认为这是不可能的,因为我无法访问TabBarController作为导出。我为@interface添加了正确的值(包括ViewController和AppDelegate),但不知道下一步该做什么。@interfaceViewController:UIViewController我希望我不必摆脱整个应用程序模板,并且可以将在IB中创建的TabBarControlle

ios - 从应用程序委托(delegate)获取当前 View Controller (模态是可能的)

我知道要从应用委托(delegate)获取当前ViewController,我可以使用为我的应用设置的navigationController属性。但是,在我的应用程序的许多地方,模态导航Controller可能已经呈现。有什么方法可以从应用程序委托(delegate)中检测到这一点,因为当前的导航Controller将不同于应用程序委托(delegate)持有引用的导航Controller? 最佳答案 基于gisthere,我创建了一个类别来获取最顶层的ViewController,这样调用[[UIApplicationshare