Skip to content

Commit

Permalink
Temporary disabled categories screen rotation until it is working well
Browse files Browse the repository at this point in the history
  • Loading branch information
akervern committed Dec 14, 2011
1 parent 07162a2 commit c3b16cd
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions iOS/sosmessage/sosmessage/SMCategoriesViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@
#import "SMMessageViewController.h"
#import "SMAboutViewController.h"

@interface SMCategoriesViewController () {

}
-(BOOL)isSubViewCategoryPart:(UIView*) view;
@end

@implementation SMCategoriesViewController
@synthesize infoButton;
@synthesize categories;
Expand Down Expand Up @@ -49,7 +55,7 @@ - (void)viewWillAppear:(BOOL)animated
[super viewWillAppear:animated];

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshCategories) name:UIDeviceOrientationDidChangeNotification object:nil];
// [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshCategories) name:UIDeviceOrientationDidChangeNotification object:nil];
}

- (void)viewDidAppear:(BOOL)animated
Expand All @@ -73,7 +79,7 @@ - (void)viewDidDisappear:(BOOL)animated

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
return NO;
}

#pragma mark Category handling
Expand Down Expand Up @@ -131,6 +137,7 @@ - (void)fillEmptyBlocks:(int)nb fromPosX:(int)posX andPosY:(int)posY {
}

- (void)refreshCategories {
NSLog(@"Categories refreshed");
[self removeCategoriesLabel];

NSMutableArray* workingCategories = [[NSMutableArray alloc] initWithArray:categories];
Expand Down Expand Up @@ -165,7 +172,7 @@ - (void)refreshCategories {
if (x == 0) {
y -= 1;
}
float fitHeight = self.view.bounds.size.height / (y + 1);
float fitHeight = ceilf(self.view.bounds.size.height / (y + 1));
for (UIView* subView in self.view.subviews) {
if (subView.tag != 0) {
continue;
Expand All @@ -181,9 +188,13 @@ - (void)refreshCategories {
}
}

-(BOOL)isSubViewCategoryPart:(UIView*) view {
return ([view isKindOfClass:[UILabel class]] || [view isKindOfClass:[UILabel class]]) && view.tag == 0;
}

-(void)removeCategoriesLabel {
for (UIView* subView in self.view.subviews) {
if ([subView isKindOfClass:[UILabel class]] && subView.tag == 0) {
if ([self isSubViewCategoryPart:subView]) {
[subView removeFromSuperview];
}
}
Expand Down

0 comments on commit c3b16cd

Please sign in to comment.