Fixing crash on notification style setting

pull/1/head
Frederic Jacobs 10 years ago
parent eb8c3e57ed
commit db74e17564

@ -76,6 +76,14 @@
#define _iOS_8_0 NSFoundationVersionNumber_iOS_8_0 #define _iOS_8_0 NSFoundationVersionNumber_iOS_8_0
#endif #endif
#ifndef NSFoundationVersionNumber_iOS_8_0_2
#define NSFoundationVersionNumber_iOS_8_0_2 1140.110000 //extracted with NSLog(@"%f", NSFoundationVersionNumber)
#endif
#ifdef NSFoundationVersionNumber_iOS_8_0_2
#define _iOS_8_0_2 NSFoundationVersionNumber_iOS_8_0_2
#endif
/** /**
Add a Singelton implementation to the .m File Add a Singelton implementation to the .m File

@ -294,7 +294,7 @@
return [NSString stringWithFormat:@"%@ : %@", name, message.body]; return [NSString stringWithFormat:@"%@ : %@", name, message.body];
break; break;
default: default:
DDLogWarn(@"Unexpected notification type %ld", setting); DDLogWarn(@"Unexpected notification type %u", setting);
break; break;
} }
} }

@ -18,32 +18,36 @@
@implementation NotificationPreviewViewController @implementation NotificationPreviewViewController
- (void)viewDidLoad { - (void)viewDidLoad
{
[super viewDidLoad]; [super viewDidLoad];
self.navigationItem.title = @"Notification Style"; self.navigationItem.title = @"Notification Style";
self.tableView.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero]; self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
self.clearsSelectionOnViewWillAppear = NO; self.clearsSelectionOnViewWillAppear = NO;
} }
- (void)didReceiveMemoryWarning { - (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning]; [super didReceiveMemoryWarning];
} }
-(void)viewWillAppear:(BOOL)animated - (void)viewWillAppear:(BOOL)animated
{ {
[super viewWillAppear:animated]; [super viewWillAppear:animated];
NSInteger currentSetting = (NSInteger)[Environment.preferences notificationPreviewType]; NSInteger currentSetting = (NSInteger)[Environment.preferences notificationPreviewType];
_defaultSelectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:currentSetting+1]; _defaultSelectedIndexPath = [NSIndexPath indexPathForRow:0 inSection:currentSetting + 1];
[self selectRowAtIndexPath:_defaultSelectedIndexPath]; [self selectRowAtIndexPath:_defaultSelectedIndexPath];
} }
#pragma mark - Table view data source #pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4; return 4;
} }
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1; return 1;
} }
@ -51,48 +55,46 @@
{ {
UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view; UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
[header.textLabel setTextColor:[UIColor blackColor]]; [header.textLabel setTextColor:[UIColor blackColor]];
[header.textLabel setFont:[UIFont ows_thinFontWithSize:14.0f]]; if (SYSTEM_VERSION_GREATER_THAN(_iOS_8_0_2)) {
[header.textLabel setFont:[UIFont ows_thinFontWithSize:14.0f]];
}
} }
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (_defaultSelectedIndexPath != nil && ![_defaultSelectedIndexPath isEqual:indexPath]) {
if (_defaultSelectedIndexPath != nil && ![_defaultSelectedIndexPath isEqual:indexPath])
{
[self deselectRowAtIndexPath:_defaultSelectedIndexPath]; [self deselectRowAtIndexPath:_defaultSelectedIndexPath];
_defaultSelectedIndexPath = nil; _defaultSelectedIndexPath = nil;
} }
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexPath]; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryCheckmark; cell.accessoryType = UITableViewCellAccessoryCheckmark;
switch (indexPath.section) { switch (indexPath.section) {
case 1: case 1:
[Environment.preferences setNotificationPreviewType:NotificationNoNameNoPreview]; [Environment.preferences setNotificationPreviewType:NotificationNoNameNoPreview];
break; break;
case 2: case 2:
[Environment.preferences setNotificationPreviewType:NotificationNameNoPreview]; [Environment.preferences setNotificationPreviewType:NotificationNameNoPreview];
break; break;
case 3: case 3:
[Environment.preferences setNotificationPreviewType:NotificationNamePreview]; [Environment.preferences setNotificationPreviewType:NotificationNamePreview];
break; break;
default: default:
break; break;
} }
} }
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
UITableViewCell * cell = [self.tableView cellForRowAtIndexPath:indexPath]; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.accessoryType = UITableViewCellAccessoryNone; cell.accessoryType = UITableViewCellAccessoryNone;
} }
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{ {
if (indexPath.section == 0) { if (indexPath.section == 0) {
return 120.0f; return 120.0f;
@ -103,16 +105,14 @@
#pragma mark - Cell selection proxy #pragma mark - Cell selection proxy
-(void)selectRowAtIndexPath:(NSIndexPath*)indexPath - (void)selectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
[self.tableView.delegate tableView:self.tableView didSelectRowAtIndexPath:indexPath]; [self.tableView.delegate tableView:self.tableView didSelectRowAtIndexPath:indexPath];
} }
-(void)deselectRowAtIndexPath:(NSIndexPath*)indexPath - (void)deselectRowAtIndexPath:(NSIndexPath *)indexPath
{ {
[self.tableView.delegate tableView:self.tableView didDeselectRowAtIndexPath:indexPath]; [self.tableView.delegate tableView:self.tableView didDeselectRowAtIndexPath:indexPath];
} }
@end @end

Loading…
Cancel
Save