You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
func getPhoto(callback: (Array<AnyObject>) -> ()) {
let urlPath: NSString = "some_rest_url"
let url = NSURL(string: urlPath)
let request = NSMutableURLRequest(URL: url)
request.HTTPMethod = "GET"
request.addValue("application/json", forHTTPHeaderField: "Accept")
let session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration(), delegate: self, delegateQueue: NSOperationQueue.mainQueue())
var dataTask = NSURLSessionDataTask()
dataTask = session.dataTaskWithRequest(request) { (data, response, error) in
if (error == nil) {
callback(array)
}
}
dataTask.resume()
}
override func viewDidLoad() {
super.viewDidLoad()
// Works fine here with any image.
//let venueImage = UIImage(named: "bg")
//self.tableView.addParallaxWithImage(venueImage, andHeight: 160)
// Bug occurs here, when coming from callback.
api.getPhoto() { (photos) in
let photo = photos[0] as FSPhoto
let data = NSData(contentsOfURL: NSURL.URLWithString("\(photo.prefix)300x300\(photo.suffix)"))
let venueImage = UIImage(data: data)
let venueImage = UIImage(named: venueImage)
self.tableView.addParallaxWithImage(venueImage, andHeight: 160)
}
}
First Load (from callback method):
When scrolling for the first time (either up or down), the image appears where it should be.
The image appears properly otherwise if it's just a simple call within the viewDidLoad.
The text was updated successfully, but these errors were encountered:
gotnull
changed the title
On first load image appears halfway down until first scroll (either up or down)
On first load image appears halfway down until first scroll (either up or down) from delegate method.
Jul 3, 2014
gotnull
changed the title
On first load image appears halfway down until first scroll (either up or down) from delegate method.
On first load the image appears halfway down until you first scroll (either up or down) from a callback.
Jul 3, 2014
Example code:
First Load (from callback method):
When scrolling for the first time (either up or down), the image appears where it should be.
The image appears properly otherwise if it's just a simple call within the
viewDidLoad
.The text was updated successfully, but these errors were encountered: