iOS 11只有崩溃问题 - 当我点击标签栏App崩溃时

时间:2017-10-23 12:55:04

标签: ios objective-c uiview uitabbarcontroller ios11

当我仅从hometabviewcontroller点击特定标签栏时,我遇到了崩溃错误。这只在iOS 11中发生。请帮我解决这个问题。

@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{
}

根据请求,以下是我的HomeTabView控制器的整个页面。

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

当我在iOS 11中点击tabbar-4时,此应用程序崩溃了。我不明白我的代码有什么问题。我没有在Hometabviewcontroller或accountscontroller上获得与refreshController相关的任何代码。但是当我搜索整个代码库时,我得到了以下内容。

- (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];
}

以下是特定tabview控制器的viewloads代码。

constructor(private renderer:Renderer2, private el: ElementRef ) { }

addfield()  {

  console.log('function triggered');
  const div = this.renderer.createElement('div');
  const input = this.renderer.createElement('input');

  this.renderer.appendChild(div, input);

  this.renderer.addClass(div, 'col-md-6');
  this.renderer.addClass(div, 'col-sm-6');
  this.renderer.addClass(div, 'col-xs-12');

  console.log('cross passes the code');
  this.renderer.addClass(input, 'form-control');
  this.renderer.addClass(input, 'col-md-7');
  this.renderer.addClass(input, 'col-xs-12');

}

1 个答案:

答案 0 :(得分:0)

您可以跟踪unrecognized selector sent to instance的来源。代码中的某些东西正在调用它。

hometabviewcontrollerrefreshControl的整个项目中进行文字搜索,查看调用它的位置和内容,并确保它符合您的要求。

如果这没有帮助,我们需要更多代码(最好是hometabviewcontroller)来帮助您。