delegates

Objective c - pass back string value using delegate

▼魔方 西西 提交于 2019-12-20 07:40:21
问题 I want to pass UITextField *nameText from GreenViewController to UILabel *nameValue in ViewController using delegate. I made delegate, the onSave method in ViewController is called but the screen is not going back and the name is not passed. What is the problem? Here are the header and impelentation files: GreenViewController.h #import <UIKit/UIKit.h> @protocol GreenViewDelegate <NSObject> -(void)onSave:(NSString*)nameValue; @end @interface GreenViewController : UIViewController @property id

Calling delegate function from AppDelegate not working

大憨熊 提交于 2019-12-20 07:39:12
问题 I am trying to call delegate function in AppDelegate, but seems like it never get invoked. import UIKit @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate,appdelegate { var window: UIWindow? func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { if let navigationController = window?.rootViewController, let viewController = navigationController.childViewControllers.first as?

NSURLConnection does not call complete across multiple Views

旧巷老猫 提交于 2019-12-20 07:18:02
问题 Earlier today I asked the following question: iOS block being stoped when view pushed The operation I mentioned (OP1) is actually a "http get" to my server, using NSURLConnection. After even more investigation I discovered that the block doesn't actually "die". What really happens is that the request is actually SENT (the server side logs it), even after the view is pushed (verified via [NSThread sleep:10]). The server responds but then NOTHING happens on the app side if the view2 has been

Why use delegates at all? [closed]

我与影子孤独终老i 提交于 2019-12-20 07:17:41
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . I have some questions about delegates in Objective-C: What's the point of using them at all? Why i can't just create class with all methods, that i need and then set object of this class as property (i.e. what's the convenience of using protocols)? Who invokes the methods of

Unhide buttons in VC1 from VC2 using delegate

浪子不回头ぞ 提交于 2019-12-20 06:37:33
问题 I am trying to Unhide some buttons in a ViewControl using a button in a secondary VC. On my researches I found out that I have to use a "Delegation action". I have created two classes named VC1 -> VC2 VC1.h contains: #import <UIKit/UIKit.h> @protocol CustomDelegate <NSObject> -(void)hideUnhidebutton:(BOOL)value; @end @interface VC1 : NSObject <CustomDelegate> @property (strong, nonatomic) IBOutlet UIButton *buttonToUnhide; @end in VC1.m I have implemented the function that unhide the button:

Function doesn't return a value on all code paths Vb.net

て烟熏妆下的殇ゞ 提交于 2019-12-20 06:04:20
问题 I'm somewhat new to programming and I am having trouble just making this work. I'm supposed to run this code using a delegate but I've run into error after error. I'm using Vb.net. Could anyone help me solve the issues in this code? Public Delegate Function D() Dim Str As String = Console.ReadLine() Sub Main() Dim D1 As D D1 = New D(AddressOf Fn1) End Sub Function Fn1() System.Console.WriteLine("Please enter the string") Dim revstr As String = StrReverse(Str) Console.WriteLine("Reverse:")

How can a delegate & interface be used interchangeably?

无人久伴 提交于 2019-12-20 05:15:36
问题 Can I use interface method instead of delegate? How? I found searching that interface method is faster than using delegates. I would appreciate a simple code snippet. 回答1: In theory, it's possible to accomplish everything done by delegates with interfaces (Java has no delegates, for instance) containing a single method. However, it makes the code more verbose and adds little benefit. Then again, it's possible to do everything without classes and possibly do it faster. That doesn't mean you

Swift 3 : Delegate within TapGestureRecognizer in Generics doesn't get called

牧云@^-^@ 提交于 2019-12-20 04:34:12
问题 I have a protocol like so : public protocol SubmitAgeDelegate : class { func changeSubmitButtonBool() } The problem is I want to call it in a generics class. open class GenericController<UICollectionViewCell,UICollectionReusableView> { weak var submitAgeDelegate: SubmitAgeDelegate? Within a UITapGestureRecognizer func tapGestureDidRecognize(_ gesture: UITapGestureRecognizer) { if let myAgeDelegate = self.submitAgeDelegate { print("inside delegate") //Never gets inside myAgeDelegate

PyQt listview with html rich text delegate moves text bit out of place(pic and code included)

北城余情 提交于 2019-12-20 03:47:11
问题 Got a listview where items need to make use of bold text, so a html delegate is the way to go. I looked around and found several solutions and out of them I made this code, but it has the issue that you can see in the gif, which shows the results with the use of the delegate and without. from PyQt4.QtCore import * from PyQt4.QtGui import * import sys class HTMLDelegate(QStyledItemDelegate): def __init__(self, parent=None): super(HTMLDelegate, self).__init__(parent) self.doc = QTextDocument

ListView signals and slots for menu elements

北城以北 提交于 2019-12-20 03:26:09
问题 I'm trying to implement some sort of custom Menu with custom elements. The ultimate goal is to create some sort of popup menu with text and icons. But during creation I faced with some issues. I can show 2 primary problems: There is a strange menu element with title Hello world at the first position (looks like it's read title of application window): From time to time I'm getting errors like qrc:/BreezeQuickMenu.qml:45: TypeError: Property 'clicked' of object QQuickListView(0x1120830) is not