I have a UITableView that is blank be default until the user edits and adds data to it. I want to show an image with instructions that is shown unt开发者_如何转开发il the user edits it.
The size of the picture is so it fits under perfectly between the nav bar and the tab bar.
Is there a way to do this programmatically?
you can use removeFromSuperview
to remove UITableView
from super view then add your UIImageView
.
Use the below code :
-(void) NeedView:(BOOL) aIsImageView
{
if(aIsImageView)
{
[m_TableView removeFromSuperview];
[self.view addSubviews:m_ImageView];
}
else
{
[m_ImageView removeFromSuperview];
[self.view addSubviews:m_TableView];
}
}
Create a UIView add your UITableView as a subview. Create a UIImageView with your instructions image and add it as a subView as well. Position the instructions imageView behind the the tableView. In ViewWillAppear add a test for empty table and hide the table based on that check. If you allow users to delete rows you will also have to check for empty table in:
- (void)tableView:(UITableView *)tableView
commitEditingStyle:(UITableViewCellEditingStyle)editingStyle
forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
// do delete
// get count of rows in UITableView and hide table if it's empty
}
...
It's not that difficult to achieve, you just can show the image you want to show with the specified frame (may be frame(0, 44, 320, 392)). and check for the table rows(actually the count of array that u are using to show in table) if it is nonzero just show the image and show the table otherwise.
try this concept and come back with any problem or query..
精彩评论