Is there away to measure latency for one specific page?
Can I do some requests and calculate the average to know the latency?
Is there away to measure latency for one specific page?
Can I do some requests and calculate the average to know the latency?
I need to convert
3/27/2015 5:45:00 AM
string into an NSDate object.
I tried this;
[dateFormatter setDateFormat:@"MM/dd/yyyy hh:mm:ss a"];
but it does not work.
What might be wrong that i could not figure out?
Thanks
I'm working on a cordova app
on which I have to locate the user
latitude and longitude. Using the geolocation plugin, it works fine on android devices but it display an alert asking for permission from user in iOS
. When I used the simulator I get this alert message:
Users/user/Library/Developer/CoreSimulator/Devices/783A2EFD-2976-448C-8E4E-841C985D337D/data/Containers/Bundle/Application/EFC846BB-4BA3-465C-BD44-575582E649FC/app_name.app/www/index.html would like to use your current location.
I have seen topic talking about this problem like: this but none of the provided solutions works for me.
this is my geolocation function:
function loadMyCoordonnee() {
if (navigator.geolocation) {
navigator.geolocation
.getCurrentPosition(
function(position) {
var myLatlng = new google.maps.LatLng(
position.coords.latitude,
position.coords.longitude);
window.localStorage.setItem("lattitude",
position.coords.latitude);
window.localStorage.setItem("longitude",
position.coords.longitude);
console.log('lattitude : '
+ window.localStorage.getItem("lattitude"));
console.log('longitude : '
+ window.localStorage.getItem("longitude"));
}, function(error) {
var myLatlng = new google.maps.LatLng(
47.120547402337465, 2.651801171874922);
window.localStorage.setItem("lattitude",
47.1205474023374655);
window.localStorage.setItem("longitude",
2.651801171874922);
});
} else {
window.location = "index.html";
}
}
and here where I called this function:
var app = {
initialize: function() {
this.bindEvents();
},
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
onDeviceReady: function() {
loadMyCoordonnee();
//app.receivedEvent('deviceready');
},
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
Is there any way to change the text of the alert or to disable this alert?
I'm currently working on implementing a horizontally scrollable photo gallery feature. For this, I'm using UICollectionView with the flow layout set to horizontal. The problem that I'm currently facing is with the orientation. Lets say, I launched this view in landscape and i scrolled across couple of photos and now if change orientation to portrait, i'm loosing the position where i was before in the landscape mode. i want to make sure i show the same photo centered vertically that i have before changing the orientation. please find the included source code below.
class ViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate, UICollectionViewDelegateFlowLayout {
var collectionView: UICollectionView!
private var samplePictures:[UIImage] = []
let CELL_IDENTIFIER = "photo_cell"
var currentIndex = 0
var flowLayout: UICollectionViewFlowLayout!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
samplePictures = [UIImage(named: "Photo-1.png")!, UIImage(named: "Photo-2.png")!, UIImage(named: "Photo-3.png")!, UIImage(named: "Photo-4.png")!, UIImage(named: "Photo-5.png")!, UIImage(named: "Photo-6.png")!]
flowLayout = UICollectionViewFlowLayout()
flowLayout.scrollDirection = UICollectionViewScrollDirection.Horizontal
flowLayout.minimumInteritemSpacing = 0.0
flowLayout.minimumLineSpacing = 0.0
flowLayout.sectionInset = UIEdgeInsetsMake(0.0, 0.0, 0.0, 0.0)
collectionView = UICollectionView(frame: self.view.bounds, collectionViewLayout: flowLayout)
collectionView.delegate = self
collectionView.dataSource = self
collectionView.showsHorizontalScrollIndicator = false
collectionView.showsVerticalScrollIndicator = false
collectionView.autoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth
collectionView.pagingEnabled = true
collectionView.registerClass(SampleCollectionCell.self, forCellWithReuseIdentifier: CELL_IDENTIFIER)
self.view.addSubview(collectionView)
}
override func viewWillAppear(animated: Bool) {
super.viewWillAppear(animated)
collectionView.reloadData()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return samplePictures.count
}
func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
var cell = collectionView.dequeueReusableCellWithReuseIdentifier(
CELL_IDENTIFIER, forIndexPath: indexPath) as SampleCollectionCell
cell.backgroundColor = UIColor.brownColor()
cell.imageView_sample.image = samplePictures[indexPath.item]
return cell
}
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
return self.view.bounds.size
}
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
collectionView.collectionViewLayout.invalidateLayout()
}
//supports all orientations
override func supportedInterfaceOrientations() -> Int {
return Int(UIInterfaceOrientationMask.All.rawValue)
}
//view will rotate when the interface orientation happens
override func shouldAutorotate() -> Bool {
return true
}
}
This is the source code for the CustomCollectionCell that I'm using
class SampleCollectionCell: UICollectionViewCell {
var imageView_sample: UIImageView!
override init(frame: CGRect) {
super.init(frame: frame)
imageView_sample = UIImageView(frame: self.bounds)
imageView_sample.contentMode = UIViewContentMode.ScaleAspectFit
self.contentView.addSubview(imageView_sample)
}
required init(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func layoutSubviews() {
super.layoutSubviews()
self.imageView_surveillance.frame = self.bounds
}
}
Any help is truly appreciated. The core idea behind using this is to mimic the Photo app and also update view components when i scroll a picture. Please suggest if you think this can be done in a better way.
Regards.
I am trying to show a tableview just below the text field. I am having 5 text field in this page. I want to show the same table on all the 5 text fields (created the table programatically) please can any one help me
[!] Unable to add a source with url git@github.com:CocoaPods/Specs.git
named master-1
. You can try adding it manually in ~/.cocoapods/repos
or via pod repo add
. please any help
In my project,i have a 1.MovieplayerView,2.a label with dynamic content,3.a tableView with variable number of rows.
I was doing this with all these views in scrollView.But i always have the issue with dynamic height of the label.it sometime overlaps the tableView.
I came to know that we can use customView as the tableView header.How this can be done with variable content Height and autolayout?I am new to iOS.Any suggestion ??
I know how to add a view as the header to a table.But when the contents in the view changes,it overlaps the contents of the tableView.
I went through How to resize superview to fit all subviews with autolayout?,How do I set the height of tableHeaderView (UITableView) with autolayout?
Can some one give a simple example on how to do this?Or tell me if it is better to use a scrollview and add all these views as its subviews? any suggestion would be realy helpful.Thanks.