Giter VIP home page Giter VIP logo

Comments (7)

SvenTiigi avatar SvenTiigi commented on May 23, 2024

Hey JeanPierreFig,

STLocationRequest is written from the ground up in Swift.

To present the STLocationRequestController it uses an UIViewController Extension (found in the ReadMe).

import STLocationRequest

func showLocationRequest(){
    self.showLocationRequestController(
                        setTitle: "We need your location for some awesome features",
                        setAllowButtonTitle: "Alright",
                        setNotNowButtonTitle: "Not now",
                        setMapViewAlphaValue: 0.9,
                        setBackgroundViewColor: UIColor.lightGrayColor(),
                        setDelegate: self)
}

The UIViewController Extension will load the ViewController from the embedded Storyboard. The Swift file STLocationRequestController which you initialized is only the class for the ViewController so there will be no ViewController loaded from the Storyboard if you not use the UIViewController Extension.

So to make the Swift-Extension also be visible in an Objective-C project you should fork the project and the @obj tag before the Swift classes. For more information have a look at https://developer.apple.com/library/ios/documentation/Swift/Conceptual/BuildingCocoaApps/MixandMatch.html

I will also search for an easy solution and later will give that conversation an additional comment.

from stlocationrequest.

JeanPierreFig avatar JeanPierreFig commented on May 23, 2024

ok Thank you

from stlocationrequest.

JeanPierreFig avatar JeanPierreFig commented on May 23, 2024

Ok , I got it kinda working :)

 [self showLocationRequestControllerWithSetTitle:@"ejbd" setAllowButtonTitle:@"djej" setNotNowButtonTitle:@"dej" setMapViewAlphaValue:.9 setBackgroundViewColor:[UIColor lightGrayColor] setDelegate:self];

The view does present normally with everything in place but then I get this error a few second after

'NSInvalidArgumentException', reason: '-[ViewController locationRequestControllerPresented]: unrecognized selector sent to instance 0x7fc923db9220'

from stlocationrequest.

blolo avatar blolo commented on May 23, 2024

hello Jean,
How did you solve this issue? I'm trying to add this library into my objective c code but its failing in located the delegate or the showLocationRequestControllerWithSetTitle method, thanks.

from stlocationrequest.

SvenTiigi avatar SvenTiigi commented on May 23, 2024

Hey there,

So I've added Objective-C support in the newest Release 0.2.2.

But the problem is that CocoaPods is not converting the Swift Extension File to the STLocationRequest-Swift.h Bridging Header, which will be generated if you add "use_frameworks!" in your podfile.

bildschirmfoto 2016-05-30 um 19 42 34

So a workaround would be to create a new Swift File in your project and add a bridging Header. And create a function with an parameter from type UIViewController and call the STLocationRequestController within the Swift File.

But I will try to find out why CocoaPods isn't creating an Objective-C Interface for an Swift Extension.

from stlocationrequest.

SvenTiigi avatar SvenTiigi commented on May 23, 2024

Good news for all Objective-C folks 👍

Please perform a pod update on your project so that STLocationRequest Version 1.0.1 will be installed.

With Version 1.0.1 you can now initialize an STLocationRequest Object in the following way (It also can be found in the ReadMe file).

#import "ViewController.h"
@import STLocationRequest;

@interface ViewController () <LocationRequestDelegate>

@end

@implementation ViewController

-(void)showLocationRequestController{
    STLocationRequest *locationRequest = [[STLocationRequest alloc] initWithViewController:self];
    locationRequest.titleText = @"We need your location for some awesome features";
    locationRequest.allowButtonTitle = @"Alright";
    locationRequest.notNowButtonTitle = @"Not now";
    locationRequest.mapViewAlphaValue = 0.9;
    locationRequest.backgroundViewColor = [UIColor lightGrayColor];
    locationRequest.delegate = self;
    [locationRequest presentLocationRequestController];
}

This should fix all your problems in an Objective-C environment.

from stlocationrequest.

JeanPierreFig avatar JeanPierreFig commented on May 23, 2024

Nice thanks man 👍 :)

from stlocationrequest.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.