Меню Закрыть

Has no item to show

Содержание

I have a UICollectionView with 5 sections, some sections have data and some sections (in my code it is section 2) doesn’t have (it depend on sever)
Therefore, I want to display a label ("No item") in the selection that doesn’t data.

However, I can find any idea to do that, I hope anyone can give me some suggestion or instruction to achieve it.
I would really appreciate any help

Here is my code for intergrade sections

HERE IS WHAT I WANT

6 Answers 6

You need to use UICollectionElementKindSectionFooter the same way you use section header. I build simple CollectionView example to show what i have in mind:

So basically what I do is create universal footer and hide it when there is a content to fill the cells:

The basic example is:

Where my self.collectionViewData is an NSArray of NSDictionary .

But to avoid breaking constraints i highly recomment to create separate xib for footer and apply both for your collectionView.

You can download example project here to have a look: https://bitbucket.org/Kettu/so_34526276

Let’s assume that you have your data (items) for each section in a NSArray .

So you have the goldSectionItems array, silverSectionItems array, bronzeSectionItems array, greenSectionItems array and otherSectionItems array.

What you want to do is:

  1. when you have some items in the section you want to display them
  2. when you have no items in the section you want to display "No item"

In case 1, you want to indicate to the collection view the number of items you have in your section, using your array that contains your items.

In case 2, you want to indicate to the collection view that you have 1 item, which will be the "No item" cell.

Читайте также:  Battlefield 5 видео обзор

Note: MAX will return the maximum value between its two operands. For example if your silverSectionItems array is empty then the count property will return 0 , so the MAX(1, 0) will return 1. If your silverSectionItems is not empty count will return N (where N>1 ) so the MAX(1, N) will return N .

Then in your -collectionView:cellForItemAtIndexPath: you want to check in which case you are:

If you are in case 1 you want a cell that displays normal content.

If you are in case 2 you want a cell that displays "No item".

Feel to ask anything you do not understand.

Comments

Copy link Quote reply

derboehsevincent commented Mar 24, 2017 •

Even though this is completly in russian I was able to fill out most of the fields. Nevertheless I don’t see anyone in the list

apache error log is saying
[Fri Mar 24 11:21:14 2017] [error] [client 192.168.5.39] PHP Notice: Undefined index: dn in /var/www/tb/auth.php on line 23, referer: http://192.168.4.66/tb/index.php?bookmark_name=*&bookmark_attr=company&menu_marker=si_alph_staff_list [Fri Mar 24 11:21:14 2017] [error] [client 192.168.5.39] PHP Notice: Undefined index: dn in /var/www/tb/index.php on line 86, referer: http://192.168.4.66/tb/index.php?bookmark_name=*&bookmark_attr=company&menu_marker=si_alph_staff_list [Fri Mar 24 11:21:14 2017] [error] [client 192.168.5.39] PHP Notice: Undefined index: dn in /var/www/tb/index.php on line 134, referer: http://192.168.4.66/tb/index.php?bookmark_name=*&bookmark_attr=company&menu_marker=si_alph_staff_list [Fri Mar 24 11:21:14 2017] [error] [client 192.168.5.39] PHP Notice: Undefined index: dn in /var/www/tb/libs/profile.php on line 2, referer: http://192.168.4.66/tb/index.php?bookmark_name=*&bookmark_attr=company&menu_marker=si_alph_staff_list

What did I miss?

This comment has been minimized.

Copy link Quote reply

K0NCTANT1N commented Apr 13, 2017

I have the same errors. What do I wrong?
У меня такие же ошибки. Что я делаю не так?

Looks like the 1.63 patch/update has broken the Quicksilver vendor window for some.

Читайте также:  Создам группу в соц сетях

This game is more broken than an orphan on Xmas with no presents. Not only that, the orphan was made to watch happy children open presents with their loving parents lovingly looking on, with love in the twinkle of their eyes.

There. I think I painted a fair representation that reflects not only my mind, but my huge heart, too. Yes. My heart is huge. It is a huge pulsing organ. How hilarious is that? I ask you. Rhetorically. Obviously.

But, enough of my serious chatter.

Actually, I am a recently reconverted recruit who fell for the hype at the very start of the NMS saga, despite avoiding the hype with great effort. It was humiliating to discover a universe a kerchillion miles wide, but only an inch deep. Like all the other suckers, I went into total denial and pretended the game didn’t exist. Ever. After a year of crying into my pillow late at night and licking my wounds, which is disgusting, by the way. Who the hell wants to lick their scabs and scars? I ask you. Again. See above.

Then, out of the blue, it returned. New and improved NMS, now with more sky, because NMS loves you. People, actual people, actually said it was actually not bad. Actually. It was time to heal my wounds without my tongue. Also, the wet pillow thing was really getting annoying. Adorably, I returned to NMS. And, you know something? It still sucked. But, it didn’t, at the same time. There was something compelling me to build a base. Building bases is like skinning a live hippo for me. Easy peasy, lemon. umm I forget the rest. Long story longer, I resettled and prospered, like those prosperous people everyone talks about.

Читайте также:  Kingston hyperx khx1600c9d3 4gx характеристики

I’m in a good place with NMS and I want to make the relationship work. However, it’s tricky when the game starts fraying on the edges. Notice how quick the Anomoly car park lost its new Anomoly smell? Anomolies don’t lose that smell so fast in my experience. I hope, nay, I pray, the devs find a way to remove the thumbs (not necessarily their own thumbs) currently lodged in their anal cavity and recreation center in order to eliminate the annoying little bugs that have popped up recently.

Getting stuck in my Freighter bulkhead, like a common troll or an Armenian. Admittedly, adding Armenians was a random choice, which only makes the problem worse! Those bloody Exotic ships with tall fins that appear in my personal space upstairs, ruining the decor and blocking my way. Me! Yes. It’s all about me. But, let’s face facts. I am very important to myself. No doubt you’ve already fallen for my modest personality, my irresistable cheekiness and good looks. What can I say? I am a hunk of few words, packing an enormous vocabulary.

Рекомендуем к прочтению

Добавить комментарий

Ваш адрес email не будет опубликован.