UIWebview Delegates not Called

my application is creating different instance of a custom view with a uiwebview as subview in a for loop. but only the delegates of the first instance variable is called. what am i not doing right....?

here's the section of my code which does the instantiation.


if let responseData = JSONData["data"] as? [AnyObject] {

self.storySubviews = []

let dLen = responseData.count-1

for var i=dLen;i>=0;i-- {

var jsonError: NSError? = NSError()

let jsondata = NSJSONSerialization.dataWithJSONObject(responseData[i] as! [String:AnyObject], options: NSJSONWritingOptions(0), error: &jsonError)!

let jsonString = NSString(data: jsondata as NSData, encoding: NSUTF8StringEncoding)!

self.storySubviews.append(Story(data: jsonString,frame: self.container.bounds))

self.storySubviews[dLen-i].backgroundColor = UIColor.redColor()

self.container.addSubview(self.storySubviews[dLen-i])

}


the custom Story view has a uiwebvies as a subview which loads a local html file and calls a javascript fucntion when loading is complete via the "didFinishLoading" delegate.

but now only the first "Story" view calls the delegat.

what can i do to remedy the situation.

thanks

This sample of code is not enough for someone to help. You would need to provide a sample of code where you actually set the UIWebView delegate.

private func setup() {

self.addSubview(webview!)

self.webview.delegate = self


self.load()

}

init(data: NSString, frame: CGRect) {

let bvFrame = CGRect(x: frame.origin.x+5, y: frame.origin.y+5, width: frame.size.width-10, height: frame.size.height-10)

self.webview = UIWebView(frame: bvFrame)

self.jsonString = data

super.init(frame: frame)

onLoadingDidFinish = {

let res = self.webview.stringByEvaluatingJavaScriptFromString("DisplayStory(\(self.jsonString))")

}

self.frame = frame

setup()

}


this is the part of the code that, instantiates the webview. the load function loads the local html file.

UIWebview Delegates not Called
 
 
Q