Howto create a UITableview and load more?
up vote
-2
down vote
favorite
How do I create a table view and load more using a Swift UITableview?
// my class list
var news = [NewsElement]()
// for end bottom list
override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if scrollView == tableView
if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)
if !listNews.isLoadingFooterShowing()
self.loadMore()
// load more
func loadMore()
self.offset = String(Int(offset)! + 10)
self.getJsonNews(type:"newest", offset: offset)
self.listNews.showLoadingFooter()
// my problem i caont get news list and append last list
but for me reload data no append
self.news.insert(contentsOf: news + news, at: news.count)
DispatchQueue.global().async
DispatchQueue.main.sync
self.listNews.reloadData()
self.listNews.hideLoadingFooter()
// my method for load api
func getJsonNews(type:String , offset:String)
let parameters = [
"limit":"10",
"offset":offset,
"type":type
]
let parametersH:HTTPHeaders = [
"Authorization":"Basic ==",
"x-api-key":"mykeyg154658746546546544s8ck8" ,
]
Alamofire.request(GET_NEWS, method: .post , parameters: parameters , headers: parametersH ).responseJSON (response) in
print(response.result)
switch response.result
case .success:
guard let data = response.data else return
do
let json = JSONDecoder()
let decode = try json.decode(News.self, from: data)
self.news = decode
DispatchQueue.global().async
DispatchQueue.main.sync
self.listNews.reloadData()
self.viewIndicator.alpha = 0
self.loadIndicator.alpha = 0
self.listNews.hideLoader()
catch let err
print(err)
case .failure(let error):
print(error)
ios arrays swift pagination tableview
New contributor
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
up vote
-2
down vote
favorite
How do I create a table view and load more using a Swift UITableview?
// my class list
var news = [NewsElement]()
// for end bottom list
override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if scrollView == tableView
if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)
if !listNews.isLoadingFooterShowing()
self.loadMore()
// load more
func loadMore()
self.offset = String(Int(offset)! + 10)
self.getJsonNews(type:"newest", offset: offset)
self.listNews.showLoadingFooter()
// my problem i caont get news list and append last list
but for me reload data no append
self.news.insert(contentsOf: news + news, at: news.count)
DispatchQueue.global().async
DispatchQueue.main.sync
self.listNews.reloadData()
self.listNews.hideLoadingFooter()
// my method for load api
func getJsonNews(type:String , offset:String)
let parameters = [
"limit":"10",
"offset":offset,
"type":type
]
let parametersH:HTTPHeaders = [
"Authorization":"Basic ==",
"x-api-key":"mykeyg154658746546546544s8ck8" ,
]
Alamofire.request(GET_NEWS, method: .post , parameters: parameters , headers: parametersH ).responseJSON (response) in
print(response.result)
switch response.result
case .success:
guard let data = response.data else return
do
let json = JSONDecoder()
let decode = try json.decode(News.self, from: data)
self.news = decode
DispatchQueue.global().async
DispatchQueue.main.sync
self.listNews.reloadData()
self.viewIndicator.alpha = 0
self.loadIndicator.alpha = 0
self.listNews.hideLoader()
catch let err
print(err)
case .failure(let error):
print(error)
ios arrays swift pagination tableview
New contributor
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
post yourcellRowForAt
– Augusto
Nov 10 at 14:54
add a comment |
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
How do I create a table view and load more using a Swift UITableview?
// my class list
var news = [NewsElement]()
// for end bottom list
override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if scrollView == tableView
if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)
if !listNews.isLoadingFooterShowing()
self.loadMore()
// load more
func loadMore()
self.offset = String(Int(offset)! + 10)
self.getJsonNews(type:"newest", offset: offset)
self.listNews.showLoadingFooter()
// my problem i caont get news list and append last list
but for me reload data no append
self.news.insert(contentsOf: news + news, at: news.count)
DispatchQueue.global().async
DispatchQueue.main.sync
self.listNews.reloadData()
self.listNews.hideLoadingFooter()
// my method for load api
func getJsonNews(type:String , offset:String)
let parameters = [
"limit":"10",
"offset":offset,
"type":type
]
let parametersH:HTTPHeaders = [
"Authorization":"Basic ==",
"x-api-key":"mykeyg154658746546546544s8ck8" ,
]
Alamofire.request(GET_NEWS, method: .post , parameters: parameters , headers: parametersH ).responseJSON (response) in
print(response.result)
switch response.result
case .success:
guard let data = response.data else return
do
let json = JSONDecoder()
let decode = try json.decode(News.self, from: data)
self.news = decode
DispatchQueue.global().async
DispatchQueue.main.sync
self.listNews.reloadData()
self.viewIndicator.alpha = 0
self.loadIndicator.alpha = 0
self.listNews.hideLoader()
catch let err
print(err)
case .failure(let error):
print(error)
ios arrays swift pagination tableview
New contributor
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
How do I create a table view and load more using a Swift UITableview?
// my class list
var news = [NewsElement]()
// for end bottom list
override func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool)
if scrollView == tableView
if ((scrollView.contentOffset.y + scrollView.frame.size.height) >= scrollView.contentSize.height)
if !listNews.isLoadingFooterShowing()
self.loadMore()
// load more
func loadMore()
self.offset = String(Int(offset)! + 10)
self.getJsonNews(type:"newest", offset: offset)
self.listNews.showLoadingFooter()
// my problem i caont get news list and append last list
but for me reload data no append
self.news.insert(contentsOf: news + news, at: news.count)
DispatchQueue.global().async
DispatchQueue.main.sync
self.listNews.reloadData()
self.listNews.hideLoadingFooter()
// my method for load api
func getJsonNews(type:String , offset:String)
let parameters = [
"limit":"10",
"offset":offset,
"type":type
]
let parametersH:HTTPHeaders = [
"Authorization":"Basic ==",
"x-api-key":"mykeyg154658746546546544s8ck8" ,
]
Alamofire.request(GET_NEWS, method: .post , parameters: parameters , headers: parametersH ).responseJSON (response) in
print(response.result)
switch response.result
case .success:
guard let data = response.data else return
do
let json = JSONDecoder()
let decode = try json.decode(News.self, from: data)
self.news = decode
DispatchQueue.global().async
DispatchQueue.main.sync
self.listNews.reloadData()
self.viewIndicator.alpha = 0
self.loadIndicator.alpha = 0
self.listNews.hideLoader()
catch let err
print(err)
case .failure(let error):
print(error)
ios arrays swift pagination tableview
ios arrays swift pagination tableview
New contributor
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited Nov 10 at 14:49
Graham
3,296113558
3,296113558
New contributor
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked Nov 10 at 12:04
Mohammad Akbari
1
1
New contributor
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Mohammad Akbari is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
post yourcellRowForAt
– Augusto
Nov 10 at 14:54
add a comment |
post yourcellRowForAt
– Augusto
Nov 10 at 14:54
post your
cellRowForAt– Augusto
Nov 10 at 14:54
post your
cellRowForAt– Augusto
Nov 10 at 14:54
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.
draft saved
draft discarded
Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.
Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.
Mohammad Akbari is a new contributor. Be nice, and check out our Code of Conduct.
draft saved
draft discarded
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53238757%2fhowto-create-a-uitableview-and-load-more%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
post your
cellRowForAt– Augusto
Nov 10 at 14:54