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
#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

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

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

Loading…
Cancel
Save