Tag: select器

dynamic方法名称(Objective-C)

我有几个方法,如下所示: – (void)methodA; – (void)methodB; – (void)methodC; 并根据一些条件使用它们。 现在我想dynamic地使用它们,我试过这个: NSString *methodName; if(_flag == A) methodName = @"methodA"; else if (_flag == b) methodName = @"methodB"; else methodName = @"methodC"; [self performSelector:@selector(methodName)]; 但似乎错了。 那么如何根据不同的情况为给定的接收器使用dynamic方法名? 非常感谢!

无法识别的select器发送到实例Swift 3

我想用selector实现TapGestureRecognizer ,下面是我添加tapGestureRecognizer到我的imageView的代码 let tapFirstGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(assignImage(_:))) firstImageView.isUserInteractionEnabled = true firstImageView.tag = 1 firstImageView.addGestureRecognizer(tapFirstGestureRecognizer) 这是行动方法 func assignImage(_ sender: UIImageView){ imagePicker.allowsEditing = false imagePicker.sourceType = .photoLibrary imageViewTag = sender.tag present(imagePicker, animated: true, completion: nil) } 编译器不断的说 [UITapGestureRecognizer标记]:无法识别的select器发送到实例0x6080001a7700'

用UITableViewCellSelectionStyleGrayselect颜色的UIButton

我试图设置一个UIButton的颜色为'UITableViewCellSelectionStyleGray'; 问题是,UIButton的select颜色不能设置,只有图像。 有谁知道如何使图像与UITableViewCellSelectionStyleGray所选单元格的确切颜色?

在UILabel上执行select器会产生崩溃?

我读过UILabels并不是要回应触摸事件,而是我可以使用UIButton。 然而,我不得不inheritanceUILabel来覆盖另一种方法,所以我想我不如使用一个标签来保持对我的代码的更改至less。 如何让我的标签响应触摸事件? 显示的代码和错误如下。 UILabel *tempLabel = [[UILabel alloc] initWithFrame:CGRectMake(startingPoint, 5, 10, 22)]; tempLabel.text = equationText; tempLabel.font = [UIFont systemFontOfSize:13]; [tempLabel sizeToFit]; [view addSubview:tempLabel]; [tempLabel addTarget:self action:@selector(updateLabel:) forControlEvents:UIControlEventTouchUpInside]; // UNRECOGNIZED SELECTOR SENT TO INSTANCE

以编程方式从UIBarButtonItem继续

我有三个视图控制器,每个都在导航栏的右侧和左侧各有两个button,如下面其中一个所示。 我以编程方式创build这些button,而不是编写代码在每个相应的视图控制器(VC),我决定写一个助手类,创buildbutton。 // Note: I am using FontAwesome as a third-party library. class Helper: NSObject { static func loadNavBarItems(vc: UIViewController) { let profileButton = UIBarButtonItem() let addButton = UIBarButtonItem() let attributes = [NSFontAttributeName: UIFont.fontAwesome(ofSize: 20)] as [String: Any] profileButton.setTitleTextAttributes(attributes, for: .normal) addButton.setTitleTextAttributes(attributes, for: .normal) profileButton.title = String.fontAwesomeIcon(name: .userCircle) addButton.title = String.fontAwesomeIcon(name: .plus) vc.navigationItem.leftBarButtonItem = profileButton […]

无法识别的UITapGestureRecognizerselect器发送到实例

我已经寻找解决这个问题的方法,但是找不到解决这个问题的东西。 我从UITapGestureRecognizer获取上述exception。 这是简化的代码: import UIKit; class ViewController : UIViewController, UIScrollViewDelegate { @IBOutlet weak var scrollView:UIScrollView!; var imageView:UIImageView!; override func viewDidLoad() { super.viewDidLoad(); … set up imageView/scrollView here … let doubleTapRecognizer = UITapGestureRecognizer(target: self, action: "onScrollViewDoubleTapped"); doubleTapRecognizer.numberOfTapsRequired = 2; doubleTapRecognizer.numberOfTouchesRequired = 1; scrollView.addGestureRecognizer(doubleTapRecognizer); } func onScrollViewDoubleTapped(recognizer:UITapGestureRecognizer) { } } 任何人都可以告诉这个代码有什么问题吗? 这对我来说似乎是正确的。 我怀疑它与分配ViewController作为委托scrollView(或反之亦然)? 然而,ViewController被设置为scrollView的委托。 但是,也许这是导致这个错误的其他东西?

UIImageView | 无法识别的select器发送到实例| Xcode 6.4 | iOS 8.4

我是Xcode的新手,我的任务是将代码从iOS 6.1迁移到8.4 ,但是在那里有许多被弃用的方法。 我解决了他们(我希望如此),但现在我遇到了一个新问题。 我使用的代码是这样的: [self.clientImageView sd_setImageWithURL:[NSURL URLWithString:_client.imageURL] placeholderImage:[UIImage imageNamed:@"placeholder.png"]]; 我得到这个错误: [UIImageView sd_setImageWithURL:placeholderImage:]:无法识别的select器发送到实例0x7fbe937a88b0 最后,我得到这个: *终止应用程序由于未捕获的exception“NSInvalidArgumentException”,原因:' – [UIImageView sd_setImageWithURL:placeholderImage:]:无法识别的select器发送到实例0x7fbe937a88b0' 非常感谢。

“#selector”的参数不涉及初始值设定项或方法

我有一个名为selectionDidFinish(controller:)在委托方法closuresviewController委托给出。 呈现的控制器,采用我的UIBarButtonItem协议,有一个UIBarButtonItem与一个动作附加它应该调用selectionDidFinish(controller:)方法,但它给了我“的参数#select器不参考”初始化或方法“错误。 这个错误是在这个呈现的UIViewController : class FormulaInfoViewController: UIViewController, Dismissable { weak var dismissalDelegate: DismissalDelegate? override func viewDidLoad() { super.viewDidLoad() // Xcode doesn't like this selector navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Done", style: .Plain, target: self, action: #selector(dismissalDelegate?.selectionDidFinish(self))) } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } } 我已经确认了dismissalDelegate是越来越设置到FormulasTableViewController所以我不明白为什么它不能看到dismissalDelegate?.selectionDidFinish(self)) 。 我的UIViewController的相关代码是: class […]

如何获得imageview ios中的自定义图像的像素颜色值?

我知道以前也有类似的问题。 我想要的是获取图像内的图像的RGB像素值,所以它可以是任何图像,我们想要的像素值。 这是我用来获取点击图像的点。 – (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; if ([touch tapCount] == 2) { //self.imageView.image = nil; return; } CGPoint lastPoint = [touch locationInView:self.imageViewGallery]; NSLog(@"%f",lastPoint.x); NSLog(@"%f",lastPoint.y); } 并获取图像我已粘贴此代码。 + (NSArray*)getRGBAsFromImage:(UIImage *)image atX:(int)xx andY:(int)yy count:(int)count { NSMutableArray *result = [NSMutableArray arrayWithCapacity:count]; /** It requires to get the image into your […]

无法识别的select器在归档数据时发送到实例(NSCoding)

-(void)transformObjects:(NSMutableArray*)array key:(NSString*)key { NSMutableArray* archiveArray = [[NSMutableArray alloc]initWithCapacity:array.count]; for (Furniture *furniture in array) { // The error occurs on the line below NSData *furnitureEncodedObject = [NSKeyedArchiver archivedDataWithRootObject:furniture]; [archiveArray addObject:furnitureEncodedObject]; } NSUserDefaults *userData = [NSUserDefaults standardUserDefaults]; [userData setObject:archiveArray forKey:key]; } 错误日志: 2014-03-04 10:55:27.881 AppName[10641:60b] -[Furniture encodeWithCoder:]: unrecognized selector sent to instance 0x15d43350 我不知道为什么当我尝试归档一个对象时,“无法识别select器发送到实例”。