iOS 11 only crash issue - when I tap a tab bar App is crashing

此生再无相见时 提交于 2019-12-14 03:29:01

问题


I am getting following crash error when I tap a particular tab bar only from hometabviewcontroller. This Happens only in iOS 11. Please help me to solve this issue.

    2017-10-23 16:48:57.000890+0400 FixtrProvider[2520:910402] desc: -[UIView refreshControl]: unrecognized selector sent to instance 0x10af090d0
2017-10-23 16:48:57.001223+0400 FixtrProvider[2520:910402] name: NSInvalidArgumentException
2017-10-23 16:48:57.001308+0400 FixtrProvider[2520:910402] user info: (null)
2017-10-23 16:48:57.001441+0400 FixtrProvider[2520:910402] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView refreshControl]: unrecognized selector sent to instance 0x10af090d0'

Following is the whole Page of my HomeTabView Controller according to the request.

@interface HomeTabBarController ()
{
    ChatSocketIOClient *socket;

}
@property (strong, nonatomic) UIButton *onTheJobOffTheJobButton;
@property (strong, nonatomic) NSString *status;
@property LocationTracker * locationTracker;
@property (nonatomic) NSTimer* locationUpdateTimer;
@end

@implementation HomeTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Crash bug fixing
    self.automaticallyAdjustsScrollViewInsets = NO;
    if (!socket) {
        socket  =[ChatSocketIOClient sharedInstance];
    }
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    [self tabbarImages];
}

-(void)tabbarImages
{
    NSString *homeunselect;
    NSString *homeselect;
    NSString *historyunselect;
    NSString *historyselect;
    NSString *scheduleunselect;
    NSString *scheduleselect;
    NSString *earnunselect;
    NSString *earnselect;
    NSString *proilfeunselect;
    NSString *profileselect;


    UITabBar *tabBar = self.tabBar;

    UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];
    UITabBarItem *tabBarItem2 = [tabBar.items objectAtIndex:1];
    UITabBarItem *tabBarItem3 = [tabBar.items objectAtIndex:2];
    UITabBarItem *tabBarItem4 = [tabBar.items objectAtIndex:3];
    UITabBarItem *tabBarItem5 = [tabBar.items objectAtIndex:4];

    if ([UIScreen mainScreen].bounds.size.height <= 568) {
        homeunselect = @"provider_popup_home_btn";
        homeselect = @"provider_popup_home_btn_selector";

        historyunselect = @"provider_popup_history_btn";
        historyselect = @"provider_popup_history_btn_selector";

        scheduleunselect = @"provider_popup_schedule_btn";
        scheduleselect = @"provider_popup_selector_btn_selector";

        earnunselect = @"provider_popup_earnings_btn";
        earnselect = @"provider_popup_earnings_btn_selector";

        proilfeunselect = @"provider_popup_profile_btn";
        profileselect = @"provider_popup_profile_btn_selector";
    }else if ([UIScreen mainScreen].bounds.size.height == 667){
        homeunselect = @"6provider_popup_home_btn";
        homeselect = @"6provider_popup_home_btn_selector";

        historyunselect = @"6provider_popup_history_btn";
        historyselect = @"6provider_popup_history_btn_selector";

        scheduleunselect = @"6provider_popup_schedule_btn";
        scheduleselect = @"6provider_popup_selector_btn_selector";

        earnunselect = @"6provider_popup_earnings_btn";
        earnselect = @"6provider_popup_earnings_btn_selector";

        proilfeunselect = @"6provider_popup_profile_btn";
        profileselect = @"6provider_popup_profile_btn_selector";
    }else if ([UIScreen mainScreen].bounds.size.height >= 736){
        homeunselect = @"6pprovider_popup_home_btn";
        homeselect = @"6pprovider_popup_home_btn_selector";

        historyunselect = @"6pprovider_popup_history_btn";
        historyselect = @"6pprovider_popup_history_btn_selector";

        scheduleunselect = @"6pprovider_popup_schedule_btn";
        scheduleselect = @"6pprovider_popup_selector_btn_selector";

        earnunselect = @"6pprovider_popup_earnings_btn";
        earnselect = @"6pprovider_popup_earnings_btn_selector";

        proilfeunselect = @"6pprovider_popup_profile_btn";
        profileselect = @"6pprovider_popup_profile_btn_selector";
    }


    tabBarItem1.selectedImage = [[UIImage imageNamed:homeselect] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
    tabBarItem1.image = [[UIImage imageNamed:homeunselect] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];

    tabBarItem2.selectedImage = [[UIImage imageNamed:historyselect]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
    tabBarItem2.image = [[UIImage imageNamed:historyunselect]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];

    tabBarItem3.selectedImage = [[UIImage imageNamed:scheduleselect]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
    tabBarItem3.image = [[UIImage imageNamed:scheduleunselect]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];

    tabBarItem4.selectedImage = [[UIImage imageNamed:earnselect]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
    tabBarItem4.image = [[UIImage imageNamed:earnunselect]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];

    tabBarItem5.selectedImage = [[UIImage imageNamed:profileselect]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
    tabBarItem5.image = [[UIImage imageNamed:proilfeunselect]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];

}


-(void)viewWillAppear:(BOOL)animated{
    [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"OnChatController"];
    [[NSUserDefaults standardUserDefaults]synchronize];
    self.tabBarController.tabBar.hidden = NO;
    [UIApplication sharedApplication].idleTimerDisabled = YES;
}
-(void)viewDidDisappear:(BOOL)animated{
}

This App getting crashed when I tapped tabbar-4 in iOS 11 only. I don't understand what's the wrong with my code. I didn't get any code related to refreshController either on Hometabviewcontroller or accountscontroller. but I got the following when I search entire code base.

    - (void)refresh:(UIRefreshControl *)refreshControl
{
    [refreshControl endRefreshing];
}

Following is the viewloads code of the particular tabview controller.

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{

    [super viewDidLoad];
     _paymentLogs.selected = YES;

    self.automaticallyAdjustsScrollViewInsets = NO;

   self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: UIColorFromRGB(0XfEAA26)};
}

-(void)getFinancialData{
    UIWindow *window = [[UIApplication sharedApplication]keyWindow];
    [[ProgressIndicator sharedInstance] showPIOnWindow:window withMessge:NSLocalizedString(@"Loading...",@"Loading...")];
    _pastCycle = [[NSMutableArray alloc]init];
    NSDictionary *dict =@{
                          @"ent_sess_token": [[NSUserDefaults standardUserDefaults] objectForKey:KDAcheckUserSessionToken],
                          @"ent_dev_id":  [[NSUserDefaults standardUserDefaults] objectForKey:kPMDDeviceIdKey],
                          @"ent_date_time":[Helper getCurrentDateTime],
                          @"ent_pro_id": [[NSUserDefaults standardUserDefaults] objectForKey:@"ProviderId"]
                          };
    NetworkHandler *handler  =[NetworkHandler sharedInstance];
    [handler composeRequestWithMethod:@"GetFinancialData"
                              paramas:dict
                         onComplition:^(BOOL succeeded, NSDictionary *response) {
                             if (succeeded) {
                                 _pastCycle = [response[@"pastCycle"] mutableCopy];
                                 _currentCycle = response[@"currentCycle"];
                                 NSLog(@"financial data %@",response);
                                 [self.currentTableView reloadData];
                                 [self.pastTableView reloadData];
                                 [[ProgressIndicator sharedInstance] hideProgressIndicator];
                             }
                         }];
}

-(void)viewWillAppear:(BOOL)animated{
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(userSessionTokenExpire) name:@"HandleAcceptAndRejectFromAdmin" object:nil];

}
-(void)viewWillDisappear:(BOOL)animated{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"HandleAcceptAndRejectFromAdmin" object:nil];

}

-(void)userSessionTokenExpire{

    [[NSUserDefaults standardUserDefaults] removeObjectForKey:KDAcheckUserSessionToken];
    [[NSUserDefaults standardUserDefaults] synchronize];
    ProgressIndicator *pi = [ProgressIndicator sharedInstance];
    [pi hideProgressIndicator];
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
                                @"Main" bundle:[NSBundle mainBundle]];
    iServeSplashController *splah = [storyboard instantiateViewControllerWithIdentifier:@"splash"];
    self.navigationController.viewControllers = [NSArray arrayWithObjects:splah, nil];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}



-(void)viewDidAppear:(BOOL)animated {
    _pastCycle = [[NSMutableArray alloc]init];
    [self getFinancialData];
    [super viewDidAppear:animated];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(accountDeactivated) name:@"accountDeactivated" object:nil];
}

-(void)viewDidDisappear:(BOOL)animated {

    [super viewDidDisappear:animated];

    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

回答1:


You can track where the unrecognized selector sent to instance comes from. Something in your code is calling it.

Do a text search in hometabviewcontroller or entire project for refreshControl and see where and what is calling it and make sure it's what you want.

If that does not help we need more code (preferably hometabviewcontroller) to help you.



来源:https://stackoverflow.com/questions/46889903/ios-11-only-crash-issue-when-i-tap-a-tab-bar-app-is-crashing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!