草庐IT

delegating

全部标签

ios - Swift 4.2 委托(delegate)和协议(protocol)不起作用

我有UIViewController(profileViewController),其中有collectionView,collectionView有headerCell其中有segmentedControl,当segmentedControl值改变时,我想老虎delegate方法但它不起作用,在这里是代码,这是collectioviewheadercell和协议(protocol)的类。importUIKit//ProtocolprotocolheaderCellSegmentedDelegate{funcchangeTabe(whichOne:String)}//HeaderCel

ios - 如何从委托(delegate)方法启动 UIAlertController?

我的代码非常基础。我有2个ViewController。在名为“FirstScreen”的第一个viewController上有一个按钮,通过模式转场将我带到第二个屏幕,那里也有一个按钮。“SecondScreen”有一个带有1方法的协议(protocol),“FirstScreen”符合该协议(protocol)。所以基本上我试图从该方法调用UIAlertController,同时按下“SecondScreen”的按钮。结果我得到:"Warning:Attempttopresent.....on....whoseviewisnotinthewindowhierarchy!我知道我可以

ios - 为什么要使用委托(delegate)?

关闭。这个问题需要更多focused.它目前不接受答案。想改进这个问题吗?更新问题,使其只关注一个问题editingthispost.关闭7年前。Improvethisquestion我对Objective-C中的委托(delegate)有一些疑问:使用它们有什么意义?为什么我不能用我需要的所有方法创建类,然后将此类的对象设置为属性(即使用协议(protocol)有什么便利)?谁调用AppDelegate的方法?为什么这些方法有一个类,而不是一个协议(protocol)?我读到,委托(delegate)方法包含诸如“做过”、“将”、“应该”、“成为”之类的词。那么为什么ViewCont

ios - "self.delegate = self"无法在使用 ARC 的 iOS 上工作

我正在开发启用了ARC的iOSSDK4项目。我的类MyTextView(派生自具有UITextViewDelegate协议(protocol)的UITextView)实现了以下静态方法:+(void)showInViewController:(UIViewController*)viewController{MyTextView*textEdit=[[MyTextViewalloc]init];textEdit.delegate=textEdit;[viewController.viewaddSubview:textEdit];//Showthekeyboard[textEditbec

ios - 在 Storyboard中,Popoverview 不接收委托(delegate)

我正在按Storyboard制作示例应用程序。当制作popoverview时,我使用了这种方式-'Embedinnavigationcontroller'。但是我在使用delegate时遇到了很大的麻烦。这是不委托(delegate)给弹出View的。[ViweController.m]-(void)prepareForSegue:(UIStoryboardSegue*)seguesender:(id)sender{if([[segueidentifier]isEqualToString:@"PopRootViewController"]){NSLog(@"[seguedestinat

objective-c - 如果需要委托(delegate)函数,如何直接返回NSURLConnection加载的数据?

简短说明我想做什么:我正在使用NSURLConnection连接到作为我的API的SSL网页。服务器证书是自签名的,因此您必须接受它,例如在Web浏览器中。我在StackOverflow上找到了一个解决方案howtodothetrick(HowtouseNSURLConnectiontoconnectwithSSLforanuntrustedcert?)所以我添加了NSURLConnection委托(delegate)来使用像“didReceiveAuthenticationChallenge”这样的方法。因此我不能使用这个:NSData*response=[NSURLConnecti

ios - AVAudioPlayer 委托(delegate)不会在类方法中被调用吗?

我正在使用AVAudioPlayer并设置它的委托(delegate),但它的委托(delegate)没有被调用+(void)playflip{NSString*path;path=[[NSBundlemainBundle]pathForResource:@"flip"ofType:@"mp3"];AVAudioPlayer*flip;flip=[[AVAudioPlayeralloc]initWithContentsOfURL:[NSURLfileURLWithPath:path]error:Nil];flip.delegate=self;[flipplay];}我正在实现的类是声音

iphone - UIImagePickerController subview 未调用委托(delegate)。用作 modalViewController

我正在使用UIImagePickerController编写相机应用程序,我想将它作为subview添加到显示层次结构中:iddelegate=[[UIApplicationsharedApplication]delegate];window=[delegatewindow];picker.cameraViewTransform=CGAffineTransformMakeScale(1.3,1.3);[windowaddSubview:picker.view];[pickerviewWillAppear:YES];[pickerviewDidAppear:YES];但是当我这样做时,委

iphone - 设置 UIWebView scrollView delegate 导致错误

所以我有以下代码:NSString*currSysVer=[[UIDevicecurrentDevice]systemVersion];if([currSysVercompare:@"5.0"options:NSNumericSearch]!=NSOrderedAscending){webScrollView=self.webView_.scrollView;}else{webScrollView=[self.webView_defaultScrollView];}webScrollView.delegate=self当我滚动时,它会给我:-[UIWebViewscrollViewDi

iOS FBRequest成功委托(delegate)方法

有什么简单的方法可以从FBRequest的实例中获取成功通知吗?如-(void)request:(FBRequest*)requestdidFailWithError:(NSError*)error错误。 最佳答案 似乎唯一的方法是检查NSURLResponse的响应代码是否为200。-(void)request:(FBRequest*)requestdidReceiveResponse:(NSURLResponse*)response{if(200==[responsestatusCode]){NSLog(@"Success");