标签: unrecognized-selector

无法识别的选择器从UIButton发送到实例错误消息

我有一个以编程方式添加到tableview的UIButton.问题是,当它被触摸时,我遇到发送到实例错误消息的无法识别的选择器.

    UIButton *alertButton = [UIButton buttonWithType:UIButtonTypeInfoDark];     
    [alertButton addTarget:self.tableView action:@selector(showAlert:) 
          forControlEvents:UIControlEventTouchUpInside];
    alertButton.frame = CGRectMake(220.0, 20.0, 160.0, 40.0);

    [self.tableView addSubview:alertButton];
Run Code Online (Sandbox Code Playgroud)

这是触摸InfoDark UIButton时我想要触发的警报方法:

- (void) showAlert {
        UIAlertView *alert = 
         [[UIAlertView alloc] initWithTitle:@"My App" 
                                    message: @"Welcome to ******. \n\nSome Message........" 
                                   delegate:nil 
                          cancelButtonTitle:@"Dismiss" 
                          otherButtonTitles:nil];
        [alert show];
        [alert release];
}
Run Code Online (Sandbox Code Playgroud)

谢谢你的帮助.

iphone objective-c uibutton ios unrecognized-selector

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

为"无法识别的选择器"异常设置默认处理程序

在Objective-C中,有没有办法设置默认的处理程序以避免unrecognizedselector异常?我想做NSNULLNSNumber响应所有的方法NSString.

谢谢!

cocoa objective-c nsstring unrecognized-selector

5
推荐指数
1
解决办法
1506
查看次数

使用PhotoLibrary作为源时,UIImagePickerController崩溃

我正在使用xcode 5.1并在ios7.1和7.0.2上测试了代码.该应用程序在设备上的两种情况下与UIImagePickerController崩溃:

1)当allowsEditing设置为YES时,在我裁剪图片并按"选择"后,一旦它返回到我自己的视图,应用程序崩溃

2)在里面UIImagePickerController,当我从照片列表返回到相册列表并且我在照片列表的底部时,它崩溃了(无论allowsEditing是否是).请注意,如果我滚动照片列表,它不会崩溃.

这是我的代码:

- (IBAction)photoPickPressed:(id)sender {

    if ([self isPhotoLibraryAvailable]) {

        self.imagePicker = [[UIImagePickerController alloc] init];
        self.imagePicker.delegate = self;
        self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
        self.imagePicker.allowsEditing = YES;
        NSString *requiredMediaType = (__bridge NSString*)kUTTypeImage;
        self.imagePicker.mediaTypes = [[NSArray alloc] initWithObjects:requiredMediaType, nil];
        [self presentViewController:self.imagePicker animated:YES completion:nil];
    }
}

#pragma mark - image picker delegates
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
    [picker dismissViewControllerAnimated:YES completion:^(){
        NSLog(@"finished image picking");
    });
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker{
    [picker dismissViewControllerAnimated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)

崩溃消息是

*由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'* - [NSProxy doesNotRecognizeSelector:scrollViewDidScroll:]调用!' …

crash uiimagepickercontroller ios unrecognized-selector

5
推荐指数
1
解决办法
1277
查看次数

在iOS8中无法再访问UITableViewHeaderFooterView上的textLabel?

-(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
    UITableViewHeaderFooterView *headerIndexText = (UITableViewHeaderFooterView *)view;
    [headerIndexText.textLabel setTextColor:[UIColor whiteColor]];
}
Run Code Online (Sandbox Code Playgroud)

上面的代码在iOS6iOS7上运行良好,并且已经生产了一段时间.但是,在iPhone5S模拟器上的iOS8上运行时,应用程序崩溃时出现以下错误:

- [UIView textLabel]:无法识别的选择器发送到实例0xeccad20

这是一种不赞成使用此标签样式的方法,还是iOS8中的错误?

objective-c ios unrecognized-selector ios8

5
推荐指数
1
解决办法
1519
查看次数

iOS:应用程序崩溃" - [MFMailComposeInternalViewController _notifyCompositionDidFinish]"

根据崩溃的人在使用iPad时崩溃.他们收到的崩溃错误是-[MFMailComposeInternalViewController _notifyCompositionDidFinish]我不知道这是怎么发生的.这是例外 Crashed: com.apple.main-thread EXC_BAD_ACCESS KERN_INVALID_ADDRESS at 0x0000000c

这是原始数据

Thread : Crashed: com.apple.main-thread
0  libobjc.A.dylib                0x30fa4f46 objc_msgSend + 5
1  MessageUI                      0x252e5f01 -[MFMailComposeInternalViewController _notifyCompositionDidFinish] + 464
2  CoreFoundation                 0x23524294 __invoking___ + 68
3  CoreFoundation                 0x23451435 -[NSInvocation invoke] + 300
4  libdispatch.dylib              0x314f87bb _dispatch_call_block_and_release + 10
5  libdispatch.dylib              0x314f87a7 _dispatch_client_callout + 22
6  libdispatch.dylib              0x314fbfa3 _dispatch_main_queue_callback_4CF + 718
7  CoreFoundation                 0x234e59d1   __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 8
8  CoreFoundation                 0x234e40d1 __CFRunLoopRun + 1512
9  CoreFoundation                 0x23432211 CFRunLoopRunSpecific + 476
10 CoreFoundation                 0x23432023 …
Run Code Online (Sandbox Code Playgroud)

crash objective-c ios unrecognized-selector mfmailcomposeviewcontroller

5
推荐指数
1
解决办法
769
查看次数

__NSCFString timeIntervalSinceReferenceDate]:无法识别的选择器已发送到实例

我试图计算两次之间的持续时间差。我从JSONArray获得持续时间,我使用下面的代码

NSDate *starttime = [[NSDate alloc]init];
NSDate *endtime = [[NSDate alloc]init];
starttime = [currentRecord valueForKey:@"starttime"];
endtime = [currentRecord valueForKey:@"endtime"];
Run Code Online (Sandbox Code Playgroud)

我将上述值传递给另一种方法

+(NSString*)remaningTime:(NSDate*)startDate endDate:(NSDate*)endDate
{
 NSDateComponents *components= [[NSDateComponents alloc]init];
 NSString *durationString;

 components = [[NSCalendar currentCalendar] components:       NSCalendarUnitDay/*|NSCalendarUnitHour|NSCalendarUnitMinute*/ fromDate: endDate toDate: startDate options: 0];
}
Run Code Online (Sandbox Code Playgroud)

但我低于例外

-[__ NSCFString timeIntervalSinceReferenceDate]:无法识别的选择器已发送到实例0x78685f80

2016-12-20 15:21:37.361 nexge[1515:183039] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString timeIntervalSinceReferenceDate]: unrecognized selector sent to instance 0x78685f80'
*** First throw call stack:
(
    0   CoreFoundation                      0x03abc212 __exceptionPreprocess + 194
    1   libobjc.A.dylib …
Run Code Online (Sandbox Code Playgroud)

json objective-c nsdateformatter ios unrecognized-selector

5
推荐指数
1
解决办法
3053
查看次数

NSInvalidArgumentException"无法识别的选择器发送到实例"(使用MPMoviePlayerController)

好吧,我在RootViewController中有一个带有DetailViewController的TableView,用于显示单个记录的信息.在详细信息页面中,我必须播放多媒体文件,并且我正在使用框架MediaPlayer,根据本指南:http: //www.techotopia.com/index.php/Video_Playback_from_within_an_iOS_4_iPhone_Application

看起来一切都好,但是当我点击播放按钮时我有这个错误:

 -[DetailsViewController playmovie]: unrecognized selector sent to instance 0x9117f60

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

这些是我的文件:

在AppDelegate中我使用这个导航控制器:

[...]

// Create a table view controller
    RootViewController *rootViewController = [[RootViewController alloc]
                                              initWithStyle:UITableViewStylePlain];

    rootViewController.managedObjectContext = context;
    rootViewController.entityName = @"Porti";


    UINavigationController *aNavigationController = [[UINavigationController alloc]
                                                     initWithRootViewController:rootViewController];

    self.navigationController = aNavigationController;


    UIBarButtonItem *homeButton;
    homeButton = [[[UIBarButtonItem alloc] initWithTitle:@"              Inizio              " style:UIBarButtonItemStyleBordered target:self action:@selector(home)] autorelease];

    UIBarButtonItem *barButton;
    barButton = [[[UIBarButtonItem alloc] …
Run Code Online (Sandbox Code Playgroud)

mpmovieplayercontroller navigationcontroller ios unrecognized-selector

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

iOS - 获得一个奇怪的错误:无法识别的选择器发送到UITableView上的实例

介绍

在我当前的应用程序中,我有一个UITableView,它包含自定义单元格对象.自定义UIViewCellObjects只是标准UITableViewCell类的子类.自定义单元格保存有关运行后台上载的信息,并使用百分比完成等操作更新它们.

自定义单元格对象从后台运行的上载进程中侦听NSNotifications,当它们收到相关通知时,它们只是使用新信息(例如上载百分比)更新自己的视图控件.

现在,当上传过程完成后,我重新排序活动上传对象数组并重新加载tableview,如下所示:

-(void) uploadFinished: (NSNotification*)notification
{
    NSDictionary *userInfo = [notification userInfo];

NSNumber *uploadID = [userInfo valueForKey:@"uploadID"];

if (uploadID.integerValue == uploadActivity.uploadID)
{   
    [[ApplicationActivities getSharedActivities] markUploadAsFinished:uploadActivity];
    [parentTable reloadData];

    [self setUploadComplete];
}
}
Run Code Online (Sandbox Code Playgroud)

现在这个方法发生在tableviewcell对象中,正如你所看到的,他们调用自己的UITableView来在数组排序后立即重新加载数据.该markUploadAsFinished方法简单地重新排序的阵列,因此任何新上传完放在顶部,所以会出现这样的UITableView的.

问题

现在我遇到的问题是,当调用此方法时,我有时会收到以下错误: 'NSInvalidArgumentException',原因:' - [CALayer tableView:numberOfRowsInSection:]:无法识别的选择器发送到实例

我不是总是得到它,有时整个过程运行良好,完成的上传出现在UItableview的开头,而在其他看似随机的时间失败.我真的不知道这里发生了什么.

自定义单元格从.NIB文件加载,如下所示:

    UploadCell *cell = [activeUploadsTable dequeueReusableCellWithIdentifier:@"UploadProgressCell"];

if (cell == nil)
{
    [[NSBundle mainBundle] loadNibNamed:@"UploadCellView" owner:self options:nil];

    cell = customCell;
}
Run Code Online (Sandbox Code Playgroud)

有没有人可能对这里发生的事情有所了解?

编辑

首先,我已经跟踪了这个错误,显示在以下行:reloadData

在自定义单元格对象内部调用.

此外,似乎它发送方法的实例可以改变.我也遇到了这个错误:

'NSInvalidArgumentException', reason: '-[UIScrollViewPanGestureRecognizer tableView:numberOfRowsInSection:]: unrecognized selector sent to instance
Run Code Online (Sandbox Code Playgroud)

我真的不知道这里发生了什么.

custom-controls uitableview ios unrecognized-selector

4
推荐指数
1
解决办法
3676
查看次数

- [__ NSCFString boundingRectWithSize:options:attributes:context:]:发送到实例的无法识别的选择器

@interface PromotionsListViewController : UITableViewController 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"PromotionCell";
PromotionCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    cell = [[PromotionCell alloc] init];
}

// Configure the cell...
Promotion *promotion = [self.promotionList objectAtIndex:indexPath.row];

[cell.imgView setImageWithURL:[NSURL URLWithString:promotion.imageURL] placeholderImage:[UIImage imageNamed:@""]];
cell.lblTitle.text = promotion.promotionTitle;

return cell;
}
@interface PromotionCell : UITableViewCell

@property(nonatomic, strong) UIImageView *imgView;
@property(nonatomic, strong) UILabel *lblTitle;

@end
- (void)layoutSubviews {

if (self.lblTitle.text) {

    CGSize maxsize = CGSizeMake(300, CGFLOAT_MAX);
    NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle …
Run Code Online (Sandbox Code Playgroud)

uitableview unrecognized-selector ios7

4
推荐指数
1
解决办法
5067
查看次数

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

我想实现TapGestureRecognizerselector,下面是我添加tapGestureRecognizer到我的代码imageView

let tapFirstGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(assignImage(_:)))
firstImageView.isUserInteractionEnabled = true
firstImageView.tag = 1
firstImageView.addGestureRecognizer(tapFirstGestureRecognizer)
Run Code Online (Sandbox Code Playgroud)

这是动作方法

func assignImage(_ sender: UIImageView){
    imagePicker.allowsEditing = false
    imagePicker.sourceType = .photoLibrary
    imageViewTag = sender.tag

    present(imagePicker, animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

编译器一直在说

[UITapGestureRecognizer标签]:无法识别的选择器发送到实例0x6080001a7700'

ios unrecognized-selector uitapgesturerecognizer swift3 xcode8

4
推荐指数
1
解决办法
4026
查看次数