Comments (7)
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.
ok Thank you
from stlocationrequest.
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.
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.
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.
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.
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.
Nice thanks man 👍 :)
from stlocationrequest.
Related Issues (13)
- Can't close modally presented ViewController any more HOT 8
- Nice work. Swift 3 on the way? HOT 1
- using pod with Swift 3.0 project HOT 3
- Allow for Custom Locations HOT 2
- Cover other permissions HOT 1
- not working on IOS 11 HOT 3
- never show 3D scene once click Present STLocationRequestController -> Alright HOT 2
- Swift 4.2 Support? HOT 3
- UITapGestureRecognizer doesn't work HOT 1
- Memory leaks HOT 1
- Compilation errors in STLocationRequestController HOT 1
- The flyover part of is not working? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stlocationrequest.