ios - UIViewPageContorller calling other UIViewPage function (swift 3)? -
i newbie in ios development. trying apps call or execute function on uiviewpage uiviewpagecontroller. can 1 advise on this?
- this page load in uipageviewcontroller:
public func pageviewcontroller(_ pageviewcontroller: uipageviewcontroller, viewcontrollerafter viewcontroller: uiviewcontroller) -> uiviewcontroller?{ //refresh json file loadjsonrecords() guard let viewcontrollerindex = vcarr.index(of: viewcontroller) else { return nil } viewcontroller[ let nextindex = viewcontrollerindex + 1 guard nextindex < vcarr.count else { return vcarr.first } guard vcarr.count > nextindex else { return nil } //here start code call uiviewpage's function return vcarr[nextindex] }
- this uipageview function wish call uipageviewcontroller:
func retrievefromjsonfile() { // url of json in document directory guard let documentsdirectoryurl = filemanager.default.urls(for: >.documentdirectory, in: .userdomainmask).first else { return } let fileurl = documentsdirectoryurl.appendingpathcomponent("xxxx.json") // create read-only stream guard let stream = inputstream(url: fileurl) else { return } stream.open() defer { stream.close() } // read data .json file , transform data array { guard let parsedarray = try jsonserialization.jsonobject(with: stream, options: []) as? [[string:any]] else { return } assignvalue(passin: parsedarray) } catch { print(error) } }
Comments
Post a Comment