The word Gheib literally means anything hidden from ones senses and understanding, while the word Shahadah means anything that is apparent and evident. One thing can be a Gheib issue to one person and a Shahadah issue to another. This depends on ones spiritual limitations and his knowledge about this world. (A sentence and a half highlighted in yellow). The Quran says in this regard: Say, [The knowledge of] the Unseen [and miracles] belongs only to Allah [and depends on his command].
Knowing that the knowledge of all beings is limited and that of Allah is complete, it is obvious that knowledge of Gheib is exclusively for Allah and no one other than Him possesses this knowledge; because it is only him that utterly encompasses the world and knows of Gheib and Shahadah. In other words, to Allah everything is considered Shahadah. As for other beings, depending on their intellectual and spiritual capacity some things are known and others are hidden from their eyes and their other senses, thus they either know nothing about them or know very little.
Therefore, allocating knowledge of the unseen to Allah (swt) doesnt mean that others cant learn of some of these secrets as a result of their worthiness and through Allahs (swt) teaching. This is a blessing that Allah (swt) bestows upon certain chosen servants of His, such as the prophets and apostles. This is why we see the prophets speaking of revelation, which is considered of the unseen, or we see them foretelling future incidents that actually do take place at the time they have predicted. 
There are different opinions in regard to the infallible imams having unconditional knowledge of Gheib and other issues in such a way that they knew about all the events of the past and future including the time and place of their martyrdom.
Some have denied the imams unlimited knowledge, which would include their knowledge to the place and time of their martyrdom. However, the majority of Shia scholars argue relying on the Almightys words in the Quran: Allah will not acquaint you with the Unseen (in order to tell the believers from the hypocrites, because this is against Allahs custom), but Allah chooses from His apostles whomever He wishes (and informs them of some of the secrets that are needed for the position of leadership) and Knower of the Unseen, He does not disclose His Unseen to anyone, except to an apostle He approves of. Then He dispatches a sentinel before and behind him  , that the special servants of Allah can be informed of the Gheib on occasions which this knowledge is necessary. This meaning is also indicated in the ahadith of the imams. Imam Sadiq says in this regard: When an imam wills to know something, Allah will teach him. 
Therefore, according to these verses and ahadith and knowing that the prophets are responsible for guiding man in all spiritual and physical fields, they must possess a great amount of knowledge so that they can discharge their duty correctly, and the situation is similar to the imams that are the successors of the prophets. Therefore, they too have knowledge of the Gheib in a vast and unconditional form. 
In this regard it is narrated from Imam Sadiq that he stated: When an Imam wills to know something, Allah will teach him. 
 Man and Knowledge of the Unseen, Question 6051 (website: 6220).
 Āl-Imrān: 179 ا کاَنَ اللَّهُ لِیَذَرَ الْمُؤْمِنِینَ عَلىَ مَا أَنتُمْ عَلَیْهِ حَتىَ یَمِیزَ الخْبِیثَ مِنَ الطَّیِّبِ وَ مَا کاَنَ اللَّهُ لِیُطْلِعَکُمْ عَلىَ الْغَیْبِ وَ لَاکِنَّ اللَّهَ یجَتَبىِ مِن رُّسُلِهِ مَن یَشَاءُ فََامِنُواْ بِاللَّهِ وَ رُسُلِهِ وَ إِن تُؤْمِنُواْ وَ تَتَّقُواْ فَلَکُمْ أَجْرٌ عَظِیمٌ
 Jinn: 26 and 27 عَلِمُ الْغَیْبِ فَلَا یُظْهِرُ عَلىَ غَیْبِهِ أَحَدًاإِلَّا مَنِ ارْتَضىَ مِن رَّسُولٍ فَإِنَّهُ یَسْلُکُ مِن بَینِْ یَدَیْهِ وَ مِنْ خَلْفِهِ رَصَدًا
 Kuleini, Usul Kāfī, vol. 1, chapter on when the imams wish to know something, they know it, hadith 3. For further information, see: Man and Knowledge of the Unseen, Question 150 (website: 1056).
 However, not always knowing about Gheib is a virtue, and sometimes can be a deficiency. For example, on the night that Imam Ali slept in the Prophets bed, if he knew that he would not be harmed, then such a thing would not be a means of his spiritual growth; because, in that case, everyone would be willing to sleep in his place. In such a situation not knowing about the Gheib is considered a virtue.
 Adopted from: The Imams Supernatural Knowledge of their Martyrdoms, Question 579 (website: 631).