Skip to content

Instantly share code, notes, and snippets.

@quard8
Created August 17, 2014 18:00
Show Gist options
  • Save quard8/4e93cc43af0e67538c23 to your computer and use it in GitHub Desktop.
Save quard8/4e93cc43af0e67538c23 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
#import <DZNEmptyDataSet/UIScrollView+EmptyDataSet.h>
@interface QViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, DZNEmptyDataSetDelegate, DZNEmptyDataSetSource>
@end
#import "QViewController.h"
@interface QViewController ()
{
NSMutableArray *events;
}
@property (strong, nonatomic) IBOutlet UITableView *eventsTableView;
@end
@implementation QViewController
@synthesize eventsTableView = _eventsTableView;
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.title = @"Вечеринки";
}
- (void)viewDidLoad
{
[super viewDidLoad];
[self setTitle:@"Вечеринки"];
_eventsTableView.delegate = self;
_eventsTableView.dataSource = self;
_eventsTableView.emptyDataSetSource = self;
_eventsTableView.emptyDataSetDelegate = self;
_eventsTableView.separatorStyle = UITableViewCellSelectionStyleNone;
// A little trick for removing the cell separators
_eventsTableView.tableFooterView = [UIView new];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 0;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
return nil;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 168;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 0;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//stripped
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
return nil;
}
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
//stripped
}
#pragma mark - EmptyDataSet
- (NSAttributedString *)titleForEmptyDataSet:(UIScrollView *)scrollView {
NSString *text = @"Ничего на нашли.";
NSDictionary *attributes = @{NSFontAttributeName: [UIFont boldSystemFontOfSize:18.0],
NSForegroundColorAttributeName: [UIColor darkGrayColor]};
return [[NSAttributedString alloc] initWithString:text attributes:attributes];
}
- (NSAttributedString *)descriptionForEmptyDataSet:(UIScrollView *)scrollView {
NSString *text = @"К сожалению, в настоящий момент вечеринок не намечается :( Зайди позже!";
NSMutableParagraphStyle *paragraph = [NSMutableParagraphStyle new];
paragraph.lineBreakMode = NSLineBreakByWordWrapping;
paragraph.alignment = NSTextAlignmentCenter;
NSDictionary *attributes = @{NSFontAttributeName: [UIFont systemFontOfSize:14.0],
NSForegroundColorAttributeName: [UIColor lightGrayColor],
NSParagraphStyleAttributeName: paragraph};
return [[NSAttributedString alloc] initWithString:text attributes:attributes];
}
- (UIColor *)backgroundColorForEmptyDataSet:(UIScrollView *)scrollView {
return [UIColor whiteColor];
}
- (BOOL)emptyDataSetShouldDisplay:(UIScrollView *)scrollView {
return YES;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment