标签: unrecognized-selector

performSegueWithIdentifier中的"无法识别的选择器发送到实例"

所以我在View Controller中有一个以编程方式添加的按钮.因此我直接从我的根View Controller创建了一个push segue到下一个.已经嵌入了导航控制器.

这是我设置按钮并添加目标;

registerButton = [UIButton buttonWithType:UIButtonTypeCustom];

[registerButton addTarget:self action:@selector(pushRegisterScreen) forControlEvents:UIControlEventTouchUpInside];
Run Code Online (Sandbox Code Playgroud)

这就是pushRegisterScreen;

- (void) pushRegisterScreen
{
    [self performSegueWithIdentifier:@"registerSegue" sender:self];
}
Run Code Online (Sandbox Code Playgroud)

但这引发了这个例外;

'NSInvalidArgumentException', reason: '-[RegisterScreen _setViewDelegate:]: unrecognized selector sent to instance 0x8d70d70'
Run Code Online (Sandbox Code Playgroud)

Xcode的第一天耶!

objective-c uiviewcontroller ios unrecognized-selector segue

3
推荐指数
1
解决办法
2999
查看次数

单击按钮后,无法识别的选择器发送到实例错误

我不确定为什么会出现此错误。当我单击FirstViewController上的按钮时会发生这种情况:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FirstViewController 1ButtonPress:]: unrecognized selector sent to instance 0x10954bbd0'
Run Code Online (Sandbox Code Playgroud)

我的FirstViewController有一个按钮(1ButtonPress),它与另一个嵌入了NavigationController的ViewController进行选择(因此,在我的故事板中,选择是从FirstViewController到NavigationController)。在此SEGUE,一些数据被传输到由其他的ViewController:
First.m

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    if ([segue.identifier isEqualToString:@"abc"]) {
            UINavigationController *navController = [segue destinationViewController];
            SecondViewController *BVC = (SecondViewController *)(navController.topViewController);
        BVC.BLLImg = [UIImage imageNamed:@"SomeImage.jpg"];
        BVC.BLLTitle = @"SomeText";
    }

}
Run Code Online (Sandbox Code Playgroud)

该脚本在情节提要中具有标识符“ abc”。环顾四周,我认为它与不正确的类有关,但是第一次检查时一切看起来都很好。
还有其他原因导致我收到此错误?

objective-c uibutton ios unrecognized-selector

3
推荐指数
1
解决办法
4677
查看次数

目标C:如何解决'无法识别的选择器发送到实例'错误

我试图使用以下代码访问实例对象的属性

for (User *user in likersArray) 
{
    //Set variables for dictionary
    NSString *nameLength = [NSString stringWithFormat:@"%i",[user.nickname length]];
}
Run Code Online (Sandbox Code Playgroud)

但是,我不断收到以下错误:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString nickname]: unrecognized selector sent to instance 0x8c0f780'
Run Code Online (Sandbox Code Playgroud)

我的用户类定义如下

@interface User : NSObject <NSCoding>
{
NSString *uid;
NSString *name;
NSString *nickname;
}

@property (nonatomic, copy) NSString *uid;
@property (nonatomic, copy) NSString *name;
@property (nonatomic, copy) NSString *nickname;

@end
Run Code Online (Sandbox Code Playgroud)

objective-c ios unrecognized-selector

2
推荐指数
2
解决办法
5206
查看次数

UIButton 的 IBAction 导致无法识别的选择器发送到实例错误 (iOS)

我在使用某些 UIButton 来调用 Tab Bar 应用程序中的操作时遇到问题。

我的 .h 文件:

#import <UIKit/UIKit.h>

@interface ContactViewController : UIViewController {
    UIButton *callTollFreeButton;
    UIButton *callLocalButton;
    UIButton *emailButton;
}

@property (nonatomic, retain) IBOutlet UIButton *callTollFreeButton;
@property (nonatomic, retain) IBOutlet UIButton *callLocalButton;
@property (nonatomic, retain) IBOutlet UIButton *emailButton;

-(IBAction)callPhone:(id)sender;
-(IBAction)callTollFree:(id)sender;
-(IBAction)clickEmailButton:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)

我的 .m 文件:

#import "ContactViewController.h"

@implementation ContactViewController
@synthesize callLocalButton,callTollFreeButton,emailButton;

-(IBAction)callPhone:(id)sender {
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:7576236600"]];
}

-(IBAction)callTollFree:(id)sender{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:8003334645"]];
}

-(IBAction)clickEmailButton:(id)sender{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"mailto:email@email.com?subject=Hello"]];    
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self …
Run Code Online (Sandbox Code Playgroud)

xcode uibutton ios unrecognized-selector

2
推荐指数
1
解决办法
9650
查看次数

滑动时无法识别的选择器

我需要抓住特殊区域的滑动动作.但是调试器说unrecognized selector sent to instance

- (void)viewDidLoad
{
    UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc]
          initWithTarget:self.viewName action:@selector(didSwipe:)];
    swipeLeft.direction = UISwipeGestureRecognizerDirectionLeft;
    [self.view addGestureRecognizer:swipeLeft];
}

-(void)didSwipe:(UISwipeGestureRecognizer*)swipe{
   NSLog(@"swiped left");
}
Run Code Online (Sandbox Code Playgroud)

怎么了?

cocoa-touch objective-c ios unrecognized-selector

2
推荐指数
1
解决办法
1957
查看次数

IOS UIBarButtonItem工作正常,而UIButton导致无法识别的选择器发送到实例

我正在尝试实现一个自定义导航栏按钮项,当用户点击一个函数被调用的条形项时,我有一个选择器.如果我将条形项设置为UIBarButtonItem它只是工作正常但我必须使用自定义图像为按钮没有边框和适当的大小.

所以在viewdidload我打电话

- (void)viewDidLoad 
{
    [super viewDidLoad];
    //gear button on navigation Bar
    UIImage* imageback2 = [UIImage imageNamed:@"ICON - Gear-BarstyleItem@2x.png"];
    CGRect frameimgback2 = CGRectMake(0, 0, 40, 40);

    UIButton *backButton2 = [[UIButton alloc] initWithFrame:frameimgback2];
    [backButton2 setBackgroundImage:imageback2 forState:UIControlStateNormal];
    [backButton2 addTarget:self
                    action:@selector(setColorButtonTapped:)
          forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithCustomView:backButton2];


    UIBarButtonItem *btn3 =[[UIBarButtonItem alloc] initWithImage:imageback2 style:UIBarButtonItemStylePlain target:self action:@selector(setColorButtonTapped:)];

    self.navigationItem.rightBarButtonItem = btn2;
}

#pragma mark Callbacks

- (IBAction)setColorButtonTapped:(id)sender{
    if (_colorPicker == nil) {
        self.colorPicker = [[ColorPickerController alloc] initWithStyle:UITableViewStylePlain];
        _colorPicker.delegate = self;
        self.colorPickerPopover = [[UIPopoverController …
Run Code Online (Sandbox Code Playgroud)

objective-c uibutton uibarbuttonitem ios unrecognized-selector

2
推荐指数
1
解决办法
5897
查看次数

目标C.追踪一个无法识别的选择器

我有一个相当复杂的项目,我正在努力.我收到与无法识别的选择器相关的错误.通常我可以快速跟踪这些问题,通常只使用逻辑,否则使用NSLog或断点.我找不到这个.

追踪此问题的有条理方法是什么?

xcode objective-c selector ios unrecognized-selector

2
推荐指数
1
解决办法
279
查看次数

无法识别的选择器发送到类[NSCalendar calendarWithIdentifier]

我有一个用Swift编写的应用程序,它在iOS模拟器上运行良好.该项目的目标设置为iOS 7.1.

当我在iPhone 5s上运行应用程序时,它崩溃在以下行:

let calendar = NSCalendar(identifier: NSGregorianCalendar)
Run Code Online (Sandbox Code Playgroud)

有错误:

+[NSCalendar calendarWithIdentifier:]: unrecognized selector sent to class 0x1955eee60
Run Code Online (Sandbox Code Playgroud)

我是否必须针对iOS8与iOS7.x进行不同的调用?

nscalendar ios unrecognized-selector swift

2
推荐指数
1
解决办法
1620
查看次数

尝试通过快速桥接标头调用扩展方法时,无法识别的选择器发送到实例

我试图从Swift调用Objective-C代码.我创建了一个Swift Bridging Header,并在Objective-C文件中添加了一个导入(例如#import "UIColor+Utils.h").

该项目构建,我甚至得到代码完成,但当它试图执行该行代码时,它崩溃并说unrecognized selector sent to class.

我做错了什么?

(Xcode 6.2,iOS 8.2)

objective-c ios unrecognized-selector swift objective-c-swift-bridge

2
推荐指数
1
解决办法
3306
查看次数

使用 HealthKit 的异常

我正在使用 Xcode 创建一个带有 HealthKit 的应用程序,但是每当我尝试在 iOS 模拟器中授权 HealthKit 时,它就会崩溃。我的代码在底部。有谁知道如何解决这一问题?

func authorizeHealthKit(completion: ((success:Bool, error:NSError!) -> Void)!)
  {
// 1. Set the types you want to read from HK Store
let healthKitTypesToRead = Set(arrayLiteral:[
  HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierDateOfBirth),
  HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBloodType),
  HKObjectType.characteristicTypeForIdentifier(HKCharacteristicTypeIdentifierBiologicalSex),
  HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMass),
  HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierHeight),
  HKObjectType.workoutType()
])

// 2. Set the types you want to write to HK Store
let healthKitTypesToWrite = Set(arrayLiteral:[
  HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierBodyMassIndex),
  HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierActiveEnergyBurned),
  HKObjectType.quantityTypeForIdentifier(HKQuantityTypeIdentifierDistanceWalkingRunning),
  HKQuantityType.workoutType()
])

// 3. If the store is not available (for instance, iPad) return an error and don't go on.
if !HKHealthStore.isHealthDataAvailable() …
Run Code Online (Sandbox Code Playgroud)

crash ios unrecognized-selector healthkit

2
推荐指数
1
解决办法
506
查看次数