How to add different cell to tableview?What's the difference between the atomic and nonatomic attributes?How to detect tableView cell touched or clicked in swiftExpand and Collapse tableview cellsHow to give different tags to buttons in different TableView cells in SwiftTableView not displaying text with JSON data from API callI am trying to append a message for my tableview but it is not appending.please help meNest a UIScrollView in SwiftHow Can I Fetch Sub Category From Rest Api(Restkit) Using Expandable Tableview Cell Swift 3Swift vertical UICollectionView inside UITableViewHow to search in Firebase Database Swift
Is the order of words purely based on convention?
I transpose the source code, you transpose the input!
Is there an equivalent of cash transportation in air cargo?
Is a Middle Name a Given Name?
What should I consider when deciding whether to delay an exam?
An impressive body of work
Smallest number containing the first 11 primes as sub-strings
One-digit products in a row of numbers
Why isn't there armor to protect from spells in the Potterverse?
If a spaceship ran out of fuel somewhere in space between Earth and Mars, does it slowly drift off to the Sun?
Is there any exception that proves or suggests that the law of non-contradiction does not always apply?
What makes learning more difficult as we age?
Is it ok if I haven't decided my research topic when I first meet with a potential phd advisor?
Why would an airline put 15 passengers at once on standby?
Notebook with version-dependent cells
What would influence an alien race to map their planet in a way other than the traditional map of the Earth
Why is the Common Agricultural Policy unfavourable to the UK?
Neural network vs regression in a small sample
Why does C++ have 'Undefined Behaviour' and other languages like C# or Java don't?
How to convert what I'm singing to notes
Delete n lines skip 1 line script
Garage door sticks on a bolt
Shorten leader-line for labels with geometry-generator
How to prevent pickpocketing in busy bars?
How to add different cell to tableview?
What's the difference between the atomic and nonatomic attributes?How to detect tableView cell touched or clicked in swiftExpand and Collapse tableview cellsHow to give different tags to buttons in different TableView cells in SwiftTableView not displaying text with JSON data from API callI am trying to append a message for my tableview but it is not appending.please help meNest a UIScrollView in SwiftHow Can I Fetch Sub Category From Rest Api(Restkit) Using Expandable Tableview Cell Swift 3Swift vertical UICollectionView inside UITableViewHow to search in Firebase Database Swift
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have a tableview and I'm downloading data from firebase after that I reload tableview but I want to add more different cell to tableview too. For example my datas count is six and I want to add to second row and fifth row different cell. In the end I want to show eight cell.
I tried this code;
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
return data?.count ?? 0
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
let cell = myTableView.dequeueReusableCell(withIdentifier: "makeLiveWallpaper") as! LiveWallTableViewCell
if indexPath.row == 1
cell.titleLabel.text = "Let's make LiveWallpaper"
return cell
else
if let cell = myTableView.dequeueReusableCell(withIdentifier: "CategoryTableViewCell", for: indexPath) as? CategoryTableViewCell
cell.category = category(at: indexPath)
cell.delegate = self
cell.setScrollPosition(x: offsets[indexPath] ?? 0)
return cell
return UITableViewCell()
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
if indexPath.row == 1
return 140
else
return 255
But it is not adding new cell it is over write on cell
ios swift tableview swift4
add a comment
|
I have a tableview and I'm downloading data from firebase after that I reload tableview but I want to add more different cell to tableview too. For example my datas count is six and I want to add to second row and fifth row different cell. In the end I want to show eight cell.
I tried this code;
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
return data?.count ?? 0
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
let cell = myTableView.dequeueReusableCell(withIdentifier: "makeLiveWallpaper") as! LiveWallTableViewCell
if indexPath.row == 1
cell.titleLabel.text = "Let's make LiveWallpaper"
return cell
else
if let cell = myTableView.dequeueReusableCell(withIdentifier: "CategoryTableViewCell", for: indexPath) as? CategoryTableViewCell
cell.category = category(at: indexPath)
cell.delegate = self
cell.setScrollPosition(x: offsets[indexPath] ?? 0)
return cell
return UITableViewCell()
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
if indexPath.row == 1
return 140
else
return 255
But it is not adding new cell it is over write on cell
ios swift tableview swift4
add a comment
|
I have a tableview and I'm downloading data from firebase after that I reload tableview but I want to add more different cell to tableview too. For example my datas count is six and I want to add to second row and fifth row different cell. In the end I want to show eight cell.
I tried this code;
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
return data?.count ?? 0
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
let cell = myTableView.dequeueReusableCell(withIdentifier: "makeLiveWallpaper") as! LiveWallTableViewCell
if indexPath.row == 1
cell.titleLabel.text = "Let's make LiveWallpaper"
return cell
else
if let cell = myTableView.dequeueReusableCell(withIdentifier: "CategoryTableViewCell", for: indexPath) as? CategoryTableViewCell
cell.category = category(at: indexPath)
cell.delegate = self
cell.setScrollPosition(x: offsets[indexPath] ?? 0)
return cell
return UITableViewCell()
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
if indexPath.row == 1
return 140
else
return 255
But it is not adding new cell it is over write on cell
ios swift tableview swift4
I have a tableview and I'm downloading data from firebase after that I reload tableview but I want to add more different cell to tableview too. For example my datas count is six and I want to add to second row and fifth row different cell. In the end I want to show eight cell.
I tried this code;
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
return data?.count ?? 0
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
let cell = myTableView.dequeueReusableCell(withIdentifier: "makeLiveWallpaper") as! LiveWallTableViewCell
if indexPath.row == 1
cell.titleLabel.text = "Let's make LiveWallpaper"
return cell
else
if let cell = myTableView.dequeueReusableCell(withIdentifier: "CategoryTableViewCell", for: indexPath) as? CategoryTableViewCell
cell.category = category(at: indexPath)
cell.delegate = self
cell.setScrollPosition(x: offsets[indexPath] ?? 0)
return cell
return UITableViewCell()
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
if indexPath.row == 1
return 140
else
return 255
But it is not adding new cell it is over write on cell
ios swift tableview swift4
ios swift tableview swift4
edited Mar 28 at 19:10
Bhaumik
9131 gold badge6 silver badges17 bronze badges
9131 gold badge6 silver badges17 bronze badges
asked Mar 28 at 19:02
Sadi HakanSadi Hakan
421 silver badge11 bronze badges
421 silver badge11 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
Once you got the data update your dataSource like given below:
data.insert("", at: 1)
data.insert("", at: 4)
self.tableView.reloadData()
update your Data Source Method
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
// your custom Cell
return cell
else if indexPath.row == 5
// you custom Cell
return cell
else
// normal cell
return UITableViewCell()
Hope it will hep you.
but data is a struck it says "Cannot convert value of type 'String' to expected argument type 'Category'"
– Sadi Hakan
Mar 28 at 19:22
@SadiHakan "" is for sample here you have to add your Category object in the array.
– Muhammad Waqas Bhati
Mar 28 at 19:24
@SadiHakan it's solved or not ?
– Muhammad Waqas Bhati
Mar 28 at 19:31
yes it is solved thx
– Sadi Hakan
Mar 28 at 20:03
add a comment
|
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405096%2fhow-to-add-different-cell-to-tableview%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Once you got the data update your dataSource like given below:
data.insert("", at: 1)
data.insert("", at: 4)
self.tableView.reloadData()
update your Data Source Method
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
// your custom Cell
return cell
else if indexPath.row == 5
// you custom Cell
return cell
else
// normal cell
return UITableViewCell()
Hope it will hep you.
but data is a struck it says "Cannot convert value of type 'String' to expected argument type 'Category'"
– Sadi Hakan
Mar 28 at 19:22
@SadiHakan "" is for sample here you have to add your Category object in the array.
– Muhammad Waqas Bhati
Mar 28 at 19:24
@SadiHakan it's solved or not ?
– Muhammad Waqas Bhati
Mar 28 at 19:31
yes it is solved thx
– Sadi Hakan
Mar 28 at 20:03
add a comment
|
Once you got the data update your dataSource like given below:
data.insert("", at: 1)
data.insert("", at: 4)
self.tableView.reloadData()
update your Data Source Method
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
// your custom Cell
return cell
else if indexPath.row == 5
// you custom Cell
return cell
else
// normal cell
return UITableViewCell()
Hope it will hep you.
but data is a struck it says "Cannot convert value of type 'String' to expected argument type 'Category'"
– Sadi Hakan
Mar 28 at 19:22
@SadiHakan "" is for sample here you have to add your Category object in the array.
– Muhammad Waqas Bhati
Mar 28 at 19:24
@SadiHakan it's solved or not ?
– Muhammad Waqas Bhati
Mar 28 at 19:31
yes it is solved thx
– Sadi Hakan
Mar 28 at 20:03
add a comment
|
Once you got the data update your dataSource like given below:
data.insert("", at: 1)
data.insert("", at: 4)
self.tableView.reloadData()
update your Data Source Method
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
// your custom Cell
return cell
else if indexPath.row == 5
// you custom Cell
return cell
else
// normal cell
return UITableViewCell()
Hope it will hep you.
Once you got the data update your dataSource like given below:
data.insert("", at: 1)
data.insert("", at: 4)
self.tableView.reloadData()
update your Data Source Method
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
if indexPath.row == 1
// your custom Cell
return cell
else if indexPath.row == 5
// you custom Cell
return cell
else
// normal cell
return UITableViewCell()
Hope it will hep you.
edited Mar 28 at 20:44
Bhaumik
9131 gold badge6 silver badges17 bronze badges
9131 gold badge6 silver badges17 bronze badges
answered Mar 28 at 19:16
Muhammad Waqas BhatiMuhammad Waqas Bhati
2,05714 silver badges23 bronze badges
2,05714 silver badges23 bronze badges
but data is a struck it says "Cannot convert value of type 'String' to expected argument type 'Category'"
– Sadi Hakan
Mar 28 at 19:22
@SadiHakan "" is for sample here you have to add your Category object in the array.
– Muhammad Waqas Bhati
Mar 28 at 19:24
@SadiHakan it's solved or not ?
– Muhammad Waqas Bhati
Mar 28 at 19:31
yes it is solved thx
– Sadi Hakan
Mar 28 at 20:03
add a comment
|
but data is a struck it says "Cannot convert value of type 'String' to expected argument type 'Category'"
– Sadi Hakan
Mar 28 at 19:22
@SadiHakan "" is for sample here you have to add your Category object in the array.
– Muhammad Waqas Bhati
Mar 28 at 19:24
@SadiHakan it's solved or not ?
– Muhammad Waqas Bhati
Mar 28 at 19:31
yes it is solved thx
– Sadi Hakan
Mar 28 at 20:03
but data is a struck it says "Cannot convert value of type 'String' to expected argument type 'Category'"
– Sadi Hakan
Mar 28 at 19:22
but data is a struck it says "Cannot convert value of type 'String' to expected argument type 'Category'"
– Sadi Hakan
Mar 28 at 19:22
@SadiHakan "" is for sample here you have to add your Category object in the array.
– Muhammad Waqas Bhati
Mar 28 at 19:24
@SadiHakan "" is for sample here you have to add your Category object in the array.
– Muhammad Waqas Bhati
Mar 28 at 19:24
@SadiHakan it's solved or not ?
– Muhammad Waqas Bhati
Mar 28 at 19:31
@SadiHakan it's solved or not ?
– Muhammad Waqas Bhati
Mar 28 at 19:31
yes it is solved thx
– Sadi Hakan
Mar 28 at 20:03
yes it is solved thx
– Sadi Hakan
Mar 28 at 20:03
add a comment
|
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55405096%2fhow-to-add-different-cell-to-tableview%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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 as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown