When I create a new GMSMapView it does not load. I have other GMSMapViews in my project that do load properly. I am using the storyboard editor to assign the custom subclass of GMSMapView to a UIView. Why are the new ones not working?
I found the solution to this issue by looking at the source code for my storyboard file.
My old GMSMapViews looked like this:
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO"
id="hbm-BT-3Ow" customClass="GMSMapView">
My new ones looked like this:
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO"
id="alb-9Z-Vu8" customClass="GMSMapView"
customModule="{My Project Name}" customModuleProvider="target">
When I set the custom class to GMSMapView for a new UIView, the associated Module was 'my project' instead of 'none' as it was previously.
The issue was that I created a custom extension for GMSMapView in my project.
extension GMSMapView {
var visibleBounds: GMSCoordinateBounds {
return GMSCoordinateBounds(region: self.projection.visibleRegion())
}
}
Solution:
Changing extension GMSMapView to extension GoogleMaps.GMSMapView fixed my problem.
Related
Hi all I have an Alloy model like this
{
name: xxx,
lastName: yyy,
telephoneNumber: ["333","444","55"]
}
I want to bind a collection of this model to a table view but I don't know how to bind telephoneNumber's array.
I want to have a label for each number into telephoneNumber like this.
<Collection src="people"/>
<TableView dataCollection="people">
<TableViewRow>
<View layout="vertical">
<Label text="{name}"></Label>
<View ng-repeat="number in people.telephoneNumber">
<Label text="{number}"></Label>
</View>
</View>
</TableViewRow>
</TableView>
My question is, does exists something like angular ng-repeat for titanium alloy?
Thanks for answer
Your best bet is dataTransform function.
<TableView dataCollection="people" dataTransform="transformModel">
Then in your controller:
function transformModel(model){
var data = model.toJSON();
data.firstNumber = data.telephoneNumber[0];
return data;
}
Then you can use the property firstNumber in your alloy view and display it properly.
You can read more about dataTransform at the docs
I'm working on my app which uses a graph to visualize some data. I'm using this nice Scrollable-GraphView for that: https://github.com/philackm/Scrollable-GraphView
Because this is only a class which inherits from UIScrollView, it's not possible to use it with Interface Builder (it also doesn't have the init(withCoder:) function implemented).
I now want to add a UIView with Interface Builder, which has all the necessary constraints to be sized properly at runtime. How can I "replace" that UIView with my GraphView at runtime?
This method is used for creating my graph at runtime:
private func createDarkGraph(frame: CGRect) -> ScrollableGraphView {
let graphView = ScrollableGraphView(frame: frame)
// ... some customization
return graphView
}
In interface builder you can drag a UIScrollView and set up constraint like normal UIScrollView, and then set the class to ScrollableGraphView, select the correct module (import!!! See this link XCODE 7.1 Swift 2 Unknown class in Interface Builder file). If you get the scrollView instance from interface builder (creating outlet .etc), it must be the instance of ScrollableGraphView. That should work just fine.
I am trying to implement a custom info window on my Google Maps Marker on an iOS app. (As is done here and here for example.)
I have created a xib and a UIView class for it. It is called CustomInfoWindow.xib and the class is CustomInfoWindow.swift.
My Custom Info Window is currently blank, i.e. I have not yet added any UIControls to my xib. I have also not yet added any code to my class file.
The CustomInfoWindow.swift file basically looks like:
import UIKit
class CustomInfoWindow: UIView {}
In my ViewController for my maps my markerInfoWindow method is as follows:
func mapView(mapView: GMSMapView!, markerInfoWindow marker: GMSMarker!) -> UIView! {
let customInfoWindow = NSBundle.mainBundle().loadNibNamed("CustomInfoWindow", owner: self, options: nil)[0] as! CustomInfoWindow
return customInfoWindow
}
When I run the code and I click on one of my markers, the blank CustomInfoWindow displays fine.
The strange thing is that the moment I add any UI Element to the CustomInfoWindow.xib in the Interface Builder and run my app again then suddenly when I click on a marker the app freezes. (For example when I add a UILabel or a UIImage to the CustomInfoWindow.xib.) If I remove the UI Element then the blank nib displays fine over the marker.
If I test my nib by adding it as a subview on some View Controller then it loads fine with my UILabel and UIImage. However, when I use that same nib in the markerInfoWindow the app freezes.
What can the problem be?
UPDATE:
This issue occurred on version 1.13 of the Google Maps SDK for iOS and it turned out to be a bug on that version.
I have the same issue. It's a GoogleMaps's bug!
Freezing apperrs in version 1.13.0.
You can use:
pod 'GoogleMaps', '1.12.3'
Found the proper workaround for 1.13
Add the following code to the subclass CustomInfoWindow
override func didMoveToSuperview() {
superview?.autoresizesSubviews = false;
}
Source: https://code.google.com/p/gmaps-api-issues/issues/detail?id=9525
I want to use React Native to create some buttons that are wired to trigger methods in a Swift app. Is there a way to access TouchableHighlight instances from within a Swift UIViewController or ViewController class?
There are various options for buttons which you can find on npmjs.org. Below are a couple of options.
https://www.npmjs.com/package/react-native-button
https://www.npmjs.com/package/react-native-icon-button
But you won't find a UIButton instance most likely since that is iOS specific. What you get is a touchable element which acts like a button. You can inspect the code of these modules on GitHub to see how they work.
You can do this without installing additional Node modules by wrapping a <Text> component with a <View> component:
import React from 'react'
class ExampleButton extends React.Component {
constructor(props) {
super(props);
this.pressButton = this.pressButton.bind(this);
}
pressButton() {
console.log("The button was pressed!");
}
render() {
return(
<View>
<Text onPress={this.pressButton}>
Button Text
</Text>
</View>
);
}
}
I'm using PNChart in a UIView and overtime my method runs it adds an addition line to the graph rather than recreating the entire graph. How do I clear a UIView, before add[ing]Subview?
#IBOutlet weak var lineChart: UIView!
...
// in function
theLineChart.chartData = [actualData]
theLineChart.strokeChart()
// want to clear self.lineChart here
self.lineChart.addSubview(theLineChart)
If by “clear” you mean remove all previously added subviews from it, you could try something like:
while let subview = lineChart.subviews.last {
subview.removeFromSuperview()
}
The caveat is that lineChart should remain a plain UIView (or your self-made subclass that you know the implementation of), as otherwise it may have internal subviews that you shouldn't remove.
Then again, if it is nothing but a plain UIView, you could simply replace the whole view with a new one (this might even make it simple to cross-fade between old and new views if such is desired).