Matthijs Otterloo Matthijs Otterloo - 4 months ago 23
iOS Question

Remove settings

I'm making an iOS App, and I want to remove the Settings option when you tap the bottom bar (so only close and exit will remain). Is there any way to do this, and how?

Thanks in advance!

Answer

All the required changes are to be made inside SKTNavigationManager.m:

  1. you need to remove the "settings" option from the action sheet

Before:

- (void)mapView:(SKMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
SKTActionSheet *sheet = nil;
if ([self currentNavigationState] == SKTNavigationStateCalculatingRoute) {
    sheet = [SKTActionSheet actionSheetWithButtonTitles:@[NSLocalizedString(kSKTQuitKey, nil)] cancelButtonTitle:NSLocalizedString(kSKTCancelKey, nil)];
} else {
    sheet = [SKTActionSheet actionSheetWithButtonTitles:@[NSLocalizedString(kSKTSettingsKey, nil), NSLocalizedString(kSKTQuitKey, nil)] cancelButtonTitle:NSLocalizedString(kSKTCancelKey, nil)];
}

sheet.delegate = self;
_activeActionSheet = sheet;
[sheet showInView:_mainView];
}

After:

- (void)mapView:(SKMapView *)mapView didTapAtCoordinate:(CLLocationCoordinate2D)coordinate {
SKTActionSheet *sheet = nil;
if ([self currentNavigationState] == SKTNavigationStateCalculatingRoute) {
    sheet = [SKTActionSheet actionSheetWithButtonTitles:@[NSLocalizedString(kSKTQuitKey, nil)] cancelButtonTitle:NSLocalizedString(kSKTCancelKey, nil)];
} else {
    sheet = [SKTActionSheet actionSheetWithButtonTitles:@[ NSLocalizedString(kSKTQuitKey, nil)] cancelButtonTitle:NSLocalizedString(kSKTCancelKey, nil)];
}

sheet.delegate = self;
_activeActionSheet = sheet;
[sheet showInView:_mainView];
}
  1. change the action handler for the selected buttons (reflecting the new menu structure).

Before:

- (void)actionSheet:(SKTActionSheet *)actionSheet didSelectButtonAtIndex:(NSUInteger)index {
if (index == 0) {
    if ([self currentNavigationState] == SKTNavigationStateCalculatingRoute) {
        [self stopNavigationWithReason:SKTNavigationStopReasonUserQuit stopAudio:YES];
    } else {
        //remove states that should't exist while settings view is visible
        [self removeState:SKTNavigationStateBlockRoads];
        [self removeState:SKTNavigationStateOverview];
        [self removeState:SKTNavigationStateRouteInfo];

        [self pushNavigationStateIfNotPresent:SKTNavigationStateSettings];
    }

    [actionSheet dismissInstantly];
    self.mainView.settingsView.delegate = self;
} else if (index == 1) {
    if (self.isFreeDrive) {
        [self stopNavigationWithReason:SKTNavigationStopReasonUserQuit stopAudio:YES];
    } else {
        [self confirmStopNavigation];
    }

    [actionSheet dismiss];
}

_activeActionSheet = nil;
}

After:

(void)actionSheet:(SKTActionSheet *)actionSheet didSelectButtonAtIndex:(NSUInteger)index {
if (index == 0) {
    if (self.isFreeDrive) {
        [self stopNavigationWithReason:SKTNavigationStopReasonUserQuit stopAudio:YES];
    } else {
        [self confirmStopNavigation];
    }

    [actionSheet dismiss];
}

_activeActionSheet = nil;
}
Comments