Permalink
Browse files

* Improved landscape support in SSRatingPickerViewController

* Added UIScreen category
  • Loading branch information...
1 parent 204ac32 commit 3c163ec0d6b397a0e59404782c389dc9f4576ba8 @soffes soffes committed Feb 4, 2011
View
36 Readme.markdown
@@ -27,7 +27,8 @@ If you're using this in your project, I'd love to hear about it! [Send me an ema
### View Controllers
* [SSCollectionViewController][] - manage a collection view
-* [SSPickerViewController][] - easily create picker view controllers like the Settings app
+* [SSPickerViewController][] - easily create picker view controllers like the Settings.app
+* [SSRatingPickerViewController][] - simple view controller for rating stuff like App Store.app
* [SSViewController][] - custom modal craziness
### Misc
@@ -103,23 +104,24 @@ Here are some related libraries. Some of these used to be part of SSToolkit.
Huge thanks to [our contributors](http://github.com/samsoffes/sstoolkit/contributors), [Jake Marsh](http://deallocatedobjects.com), and [Mike Rundle](http://flyosity.com).
-[SSViewController]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSViewController.h
-[SSPickerViewController]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSPickerViewController.h
-[SSHUDView]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSHUDView.h
-[SSCollectionView]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSCollectionView.h
-[SSGradientView]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSGradientView.h
-[SSLabel]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSLabel.h
-[SSLineView]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSLineView.h
-[SSLoadingView]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSLoadingView.h
-[SSPieProgressView]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSPieProgressView.h
+[SSViewController]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSViewController.h
+[SSPickerViewController]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSPickerViewController.h
+[SSHUDView]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSHUDView.h
+[SSCollectionView]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSCollectionView.h
+[SSGradientView]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSGradientView.h
+[SSLabel]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSLabel.h
+[SSLineView]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSLineView.h
+[SSLoadingView]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSLoadingView.h
+[SSPieProgressView]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSPieProgressView.h
[SSTextField]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSTextField.h
-[SSWebView]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSWebView.h
-[SSCollectionViewController]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSCollectionViewController.h
-[SSTextField]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSTextField.h
-[SSTextView]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSTextView.h
-[SSTableViewCell]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSTableViewCell.h
-[SSDrawingMacros]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSDrawingMacros.h
+[SSWebView]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSWebView.h
+[SSCollectionViewController]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSCollectionViewController.h
+[SSTextField]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSTextField.h
+[SSTextView]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSTextView.h
+[SSTableViewCell]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSTableViewCell.h
+[SSDrawingMacros]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSDrawingMacros.h
[SSConcurrentOperation]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSConcurrentOperation.h
-[SSKeychain]: http://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSKeychain.h
+[SSKeychain]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSKeychain.h
[SSCatalog]: https://github.com/samsoffes/sstoolkit/tree/master/SSCatalog/
[SSBadgeTableViewCell]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSBadgeView.h
+[SSRatingPickerViewController]: https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/SSRatingPickerViewController.h
View
24 SSToolkit.xcodeproj/project.pbxproj
@@ -74,6 +74,10 @@
B24E9E80121DC29A0085F81E /* UIViewController+SSToolkitAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B24E9E42121DC29A0085F81E /* UIViewController+SSToolkitAdditions.m */; };
B267D3451226CE0400B66519 /* SSCollectionViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = B267D3431226CE0400B66519 /* SSCollectionViewController.h */; };
B267D3461226CE0400B66519 /* SSCollectionViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = B267D3441226CE0400B66519 /* SSCollectionViewController.m */; };
+ B279539912FC67E300FFE28D /* UIScreen+SSToolkitAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = B279539712FC67E300FFE28D /* UIScreen+SSToolkitAdditions.h */; };
+ B279539A12FC67E300FFE28D /* UIScreen+SSToolkitAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = B279539812FC67E300FFE28D /* UIScreen+SSToolkitAdditions.m */; };
+ B279539E12FC6C6F00FFE28D /* SSRatingPickerScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = B279539C12FC6C6F00FFE28D /* SSRatingPickerScrollView.h */; };
+ B279539F12FC6C6F00FFE28D /* SSRatingPickerScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = B279539D12FC6C6F00FFE28D /* SSRatingPickerScrollView.m */; };
B27B1A1B12241D3400111EA2 /* SSCollectionView.h in Headers */ = {isa = PBXBuildFile; fileRef = B27B1A1912241D3400111EA2 /* SSCollectionView.h */; };
B27B1A1C12241D3400111EA2 /* SSCollectionView.m in Sources */ = {isa = PBXBuildFile; fileRef = B27B1A1A12241D3400111EA2 /* SSCollectionView.m */; };
B27B1A2212241D6F00111EA2 /* SSCollectionViewItem.h in Headers */ = {isa = PBXBuildFile; fileRef = B27B1A2012241D6F00111EA2 /* SSCollectionViewItem.h */; };
@@ -165,6 +169,10 @@
B24E9E42121DC29A0085F81E /* UIViewController+SSToolkitAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIViewController+SSToolkitAdditions.m"; sourceTree = "<group>"; };
B267D3431226CE0400B66519 /* SSCollectionViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSCollectionViewController.h; sourceTree = "<group>"; };
B267D3441226CE0400B66519 /* SSCollectionViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSCollectionViewController.m; sourceTree = "<group>"; };
+ B279539712FC67E300FFE28D /* UIScreen+SSToolkitAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIScreen+SSToolkitAdditions.h"; sourceTree = "<group>"; };
+ B279539812FC67E300FFE28D /* UIScreen+SSToolkitAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIScreen+SSToolkitAdditions.m"; sourceTree = "<group>"; };
+ B279539C12FC6C6F00FFE28D /* SSRatingPickerScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSRatingPickerScrollView.h; sourceTree = "<group>"; };
+ B279539D12FC6C6F00FFE28D /* SSRatingPickerScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSRatingPickerScrollView.m; sourceTree = "<group>"; };
B27B1A1912241D3400111EA2 /* SSCollectionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSCollectionView.h; sourceTree = "<group>"; };
B27B1A1A12241D3400111EA2 /* SSCollectionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SSCollectionView.m; sourceTree = "<group>"; };
B27B1A2012241D6F00111EA2 /* SSCollectionViewItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SSCollectionViewItem.h; sourceTree = "<group>"; };
@@ -258,6 +266,7 @@
B2601A78122307CD005506D5 /* View Controllers */,
B2601A791223086D005506D5 /* Controls */,
B2601A8A122308E2005506D5 /* Misc */,
+ B279539B12FC6BD400FFE28D /* Private */,
B2601A6F12230794005506D5 /* Categories */,
);
path = SSToolkit;
@@ -304,6 +313,8 @@
B24E9E3A121DC29A0085F81E /* UIDevice+SSToolkitAdditions.m */,
B24E9E3B121DC29A0085F81E /* UIImage+SSToolkitAdditions.h */,
B24E9E3C121DC29A0085F81E /* UIImage+SSToolkitAdditions.m */,
+ B279539712FC67E300FFE28D /* UIScreen+SSToolkitAdditions.h */,
+ B279539812FC67E300FFE28D /* UIScreen+SSToolkitAdditions.m */,
B24E9E3D121DC29A0085F81E /* UIScrollView+SSToolkitAdditions.h */,
B24E9E3E121DC29A0085F81E /* UIScrollView+SSToolkitAdditions.m */,
B24E9E3F121DC29A0085F81E /* UIView+SSToolkitAdditions.h */,
@@ -393,6 +404,15 @@
name = Misc;
sourceTree = "<group>";
};
+ B279539B12FC6BD400FFE28D /* Private */ = {
+ isa = PBXGroup;
+ children = (
+ B279539C12FC6C6F00FFE28D /* SSRatingPickerScrollView.h */,
+ B279539D12FC6C6F00FFE28D /* SSRatingPickerScrollView.m */,
+ );
+ name = Private;
+ sourceTree = "<group>";
+ };
B2EA9F5B12F4A5B900C929D6 /* Cells */ = {
isa = PBXGroup;
children = (
@@ -453,6 +473,8 @@
B28218BE12FA6AE100BAF3C6 /* SSToolkitDefines.h in Headers */,
B28219DD12FA8EB500BAF3C6 /* SSRatingPicker.h in Headers */,
B28C6D0712FBE5C400667755 /* SSRatingPickerViewController.h in Headers */,
+ B279539912FC67E300FFE28D /* UIScreen+SSToolkitAdditions.h in Headers */,
+ B279539E12FC6C6F00FFE28D /* SSRatingPickerScrollView.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -549,6 +571,8 @@
B28218BF12FA6AE100BAF3C6 /* SSToolkitDefines.m in Sources */,
B28219DE12FA8EB500BAF3C6 /* SSRatingPicker.m in Sources */,
B28C6D0812FBE5C400667755 /* SSRatingPickerViewController.m in Sources */,
+ B279539A12FC67E300FFE28D /* UIScreen+SSToolkitAdditions.m in Sources */,
+ B279539F12FC6C6F00FFE28D /* SSRatingPickerScrollView.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
View
6 SSToolkit/SSCategories.h
@@ -25,7 +25,8 @@
#import "UIControl+SSToolkitAdditions.h"
#import "UIDevice+SSToolkitAdditions.h"
#import "UIImage+SSToolkitAdditions.h"
-#import "UIScrollview+SSToolkitAdditions.h"
+#import "UIScreen+SSToolkitAdditions.h"
+#import "UIScrollView+SSToolkitAdditions.h"
#import "UIView+SSToolkitAdditions.h"
#import "UIViewController+SSToolkitAdditions.h"
@@ -45,7 +46,8 @@
#import <SSToolkit/UIControl+SSToolkitAdditions.h>
#import <SSToolkit/UIDevice+SSToolkitAdditions.h>
#import <SSToolkit/UIImage+SSToolkitAdditions.h>
-#import <SSToolkit/UIScrollview+SSToolkitAdditions.h>
+#import <SSToolkit/UIScreen+SSToolkitAdditions.h>
+#import <SSToolkit/UIScrollView+SSToolkitAdditions.h>
#import <SSToolkit/UIView+SSToolkitAdditions.h>
#import <SSToolkit/UIViewController+SSToolkitAdditions.h>
View
30 SSToolkit/SSRatingPickerScrollView.h
@@ -0,0 +1,30 @@
+//
+// SSRatingPickerScrollView.h
+// SSToolkit
+//
+// Created by Sam Soffes on 2/4/11.
+// Copyright 2011 Sam Soffes. All rights reserved.
+//
+
+@class SSGradientView;
+@class SSRatingPicker;
+@class SSTextField;
+@class SSTextView;
+
+@interface SSRatingPickerScrollView : UIScrollView <UITextViewDelegate> {
+
+@private
+
+ UIView *_topView;
+ SSGradientView *_gradientView;
+ SSRatingPicker *_ratingPicker;
+ SSTextField *_titleTextField;
+ UIView *_lineView;
+ SSTextView *_reviewTextView;
+}
+
+@property (nonatomic, retain, readonly) SSRatingPicker *ratingPicker;
+@property (nonatomic, retain, readonly) SSTextField *titleTextField;
+@property (nonatomic, retain, readonly) SSTextView *reviewTextField;
+
+@end
View
121 SSToolkit/SSRatingPickerScrollView.m
@@ -0,0 +1,121 @@
+//
+// SSRatingPickerScrollView.m
+// SSToolkit
+//
+// Created by Sam Soffes on 2/4/11.
+// Copyright 2011 Sam Soffes. All rights reserved.
+//
+
+#import "SSRatingPickerScrollView.h"
+#import "SSGradientView.h"
+#import "SSRatingPicker.h"
+#import "SSTextField.h"
+#import "SSTextView.h"
+#import "SSDrawingMacros.h"
+
+@implementation SSRatingPickerScrollView
+
+@synthesize ratingPicker = _ratingPicker;
+@synthesize titleTextField = _titleTextField;
+@synthesize reviewTextField = _reviewTextField;
+
+#pragma mark NSObject
+
+- (void)dealloc {
+ [_topView release];
+ [_gradientView release];
+ [_ratingPicker release];
+ [_titleTextField release];
+ [_lineView release];
+ [_reviewTextField release];
+ [super dealloc];
+}
+
+
+#pragma mark UIView
+
+- (id)initWithFrame:(CGRect)frame {
+ if ((self = [super initWithFrame:frame])) {
+ self.backgroundColor = [UIColor whiteColor];
+
+ UIFont *font = [UIFont systemFontOfSize:17.0f];
+ UIColor *topColor = [UIColor colorWithRed:0.878f green:0.890f blue:0.906f alpha:1.0f];
+ UIColor *lineColor = [UIColor colorWithRed:0.839f green:0.839f blue:0.839f alpha:1.0f];
+
+ _topView = [[UIView alloc] initWithFrame:CGRectZero];
+ _topView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
+ _topView.backgroundColor = topColor;
+ [self addSubview:_topView];
+
+ _gradientView = [[SSGradientView alloc] initWithFrame:CGRectZero];
+ _gradientView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
+ _gradientView.topColor = topColor;
+ _gradientView.bottomColor = [UIColor colorWithRed:0.961f green:0.965f blue:0.973f alpha:1.0f];
+ _gradientView.bottomBorderColor = lineColor;
+ _gradientView.hasTopBorder = NO;
+ _gradientView.hasBottomBorder = YES;
+ _gradientView.showsInsets = NO;
+ [self addSubview:_gradientView];
+
+ _ratingPicker = [[SSRatingPicker alloc] initWithFrame:CGRectZero];
+ _ratingPicker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
+ _ratingPicker.backgroundColor = [UIColor clearColor];
+ [_gradientView addSubview:_ratingPicker];
+
+ _titleTextField = [[SSTextField alloc] initWithFrame:CGRectZero];
+ _titleTextField.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
+ _titleTextField.font = font;
+ _titleTextField.placeholder = @"Title";
+ _titleTextField.textEdgeInsets = UIEdgeInsetsMake(10.0f, 8.0f, 10.0f, 8.0f);
+ [self addSubview:_titleTextField];
+
+ _lineView = [[UIView alloc] initWithFrame:CGRectZero];
+ _lineView.backgroundColor = lineColor;
+ _lineView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
+ [self addSubview:_lineView];
+
+ _reviewTextView = [[SSTextView alloc] initWithFrame:CGRectZero];
+ _reviewTextView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
+ _reviewTextView.placeholder = @"Review (Optional)";
+ _reviewTextView.font = font;
+ _reviewTextView.scrollEnabled = NO;
+ _reviewTextView.delegate = self;
+ [self addSubview:_reviewTextView];
+ }
+ return self;
+}
+
+
+- (void)layoutSubviews {
+ [super layoutSubviews];
+
+ CGFloat height = [_reviewTextView sizeThatFits:CGSizeMake(self.frame.size.width, 2000.0f)].height + 91.0f;
+ height = fmax(height, 191.0f);
+ self.contentSize = CGSizeMake(self.frame.size.width, height);
+
+ CGSize size = self.contentSize;
+
+ _topView.frame = CGRectMake(0.0f, -400.0f, size.width, 400.0f);
+ _gradientView.frame = CGRectMake(0.0f, 0.0f, size.width, 48.0f);
+ _ratingPicker.frame = CGRectMake(0.0f, 0.0f, size.width, 48.0f);
+ _titleTextField.frame = CGRectMake(0.0f, 48.0f, size.width, 42.0f);
+ _lineView.frame = CGRectMake(0.0f, 90.0f, size.width, 1.0f);
+ _reviewTextView.frame = CGRectMake(0.0f, 91.0f, size.width, size.height - 91.0f);
+}
+
+
+#pragma mark UIScrollView
+
+//- (void)setContentSize:(CGSize)size {
+// [super setContentSize:size];
+// [self setNeedsDisplay];
+//}
+
+
+#pragma mark UITextViewDelegate
+
+- (void)textViewDidChange:(UITextView *)textView {
+ [self setNeedsDisplay];
+}
+
+@end
View
17 SSToolkit/SSRatingPickerViewController.h
@@ -6,22 +6,23 @@
// Copyright 2011 Sam Soffes. All rights reserved.
//
+#import "SSViewController.h"
+
+@class SSRatingPickerScrollView;
@class SSRatingPicker;
@class SSTextField;
@class SSTextView;
-@interface SSRatingPickerViewController : UIViewController <UITextViewDelegate> {
+@interface SSRatingPickerViewController : SSViewController {
@private
- UIScrollView *_scrollView;
- SSRatingPicker *_ratingPicker;
- SSTextField *_titleTextField;
- SSTextView *_reviewTextView;
+ SSRatingPickerScrollView *_scrollView;
}
-@property (nonatomic, retain) SSRatingPicker *ratingPicker;
-@property (nonatomic, retain) SSTextField *titleTextField;
-@property (nonatomic, retain) SSTextView *reviewTextField;
+@property (nonatomic, retain, readonly) UIScrollView *scrollView;
+@property (nonatomic, retain, readonly) SSRatingPicker *ratingPicker;
+@property (nonatomic, retain, readonly) SSTextField *titleTextField;
+@property (nonatomic, retain, readonly) SSTextView *reviewTextField;
@end
View
96 SSToolkit/SSRatingPickerViewController.m
@@ -7,25 +7,20 @@
//
#import "SSRatingPickerViewController.h"
-#import "SSGradientView.h"
+#import "SSRatingPickerScrollView.h"
#import "SSRatingPicker.h"
#import "SSTextField.h"
#import "SSTextView.h"
-#import "SSDrawingMacros.h"
+#import "UIScreen+SSToolkitAdditions.h"
@implementation SSRatingPickerViewController
-@synthesize ratingPicker = _ratingPicker;
-@synthesize titleTextField = _titleTextField;
-@synthesize reviewTextField = _reviewTextField;
+@synthesize scrollView = _scrollView;
#pragma mark NSObject
- (void)dealloc {
[_scrollView release];
- [_ratingPicker release];
- [_titleTextField release];
- [_reviewTextField release];
[super dealloc];
}
@@ -36,57 +31,10 @@ - (void)loadView {
[super loadView];
self.view.backgroundColor = [UIColor whiteColor];
+ self.view.autoresizesSubviews = NO;
- UIFont *font = [UIFont systemFontOfSize:17.0f];
- UIColor *topColor = [UIColor colorWithRed:0.878f green:0.890f blue:0.906f alpha:1.0f];
- UIColor *lineColor = [UIColor colorWithRed:0.839f green:0.839f blue:0.839f alpha:1.0f];
-
- _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 190.0f)];
- _scrollView.backgroundColor = [UIColor whiteColor];
- _scrollView.contentSize = CGSizeMake(320.0f, 191.0f);
+ _scrollView = [[SSRatingPickerScrollView alloc] initWithFrame:CGRectZero];
[self.view addSubview:_scrollView];
-
- UIView *top = [[UIView alloc] initWithFrame:CGRectMake(0.0f, -400.0f, 320.0f, 400.0f)];
- top.backgroundColor = topColor;
- [_scrollView addSubview:top];
- [top release];
-
- SSGradientView *gradientView = [[SSGradientView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
- gradientView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
- gradientView.topColor = topColor;
- gradientView.bottomColor = [UIColor colorWithRed:0.961f green:0.965f blue:0.973f alpha:1.0f];
- gradientView.bottomBorderColor = lineColor;
- gradientView.hasTopBorder = NO;
- gradientView.hasBottomBorder = YES;
- gradientView.showsInsets = NO;
- [_scrollView addSubview:gradientView];
-
- SSRatingPicker *picker = [[SSRatingPicker alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 48.0f)];
- picker.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
- picker.backgroundColor = [UIColor clearColor];
- [gradientView addSubview:picker];
- [picker release];
- [gradientView release];
-
- _titleTextField = [[SSTextField alloc] initWithFrame:CGRectMake(0.0f, 48.0f, 320.0f, 42.0f)];
- _titleTextField.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
- _titleTextField.font = font;
- _titleTextField.placeholder = @"Title";
- _titleTextField.textEdgeInsets = UIEdgeInsetsMake(10.0f, 8.0f, 10.0f, 8.0f);
- [_scrollView addSubview:_titleTextField];
-
- UIView *line = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 90.0f, 320.0f, 1.0f)];
- line.backgroundColor = lineColor;
- line.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin;
- [_scrollView addSubview:line];
- [line release];
-
- _reviewTextView = [[SSTextView alloc] initWithFrame:CGRectMake(0.0f, 91.0f, 320.0f, 99.0f)];
- _reviewTextView.placeholder = @"Review (Optional)";
- _reviewTextView.font = font;
- _reviewTextView.scrollEnabled = NO;
- _reviewTextView.delegate = self;
- [_scrollView addSubview:_reviewTextView];
}
@@ -100,26 +48,36 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfa
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
- [_titleTextField becomeFirstResponder];
+ [self.titleTextField becomeFirstResponder];
}
-#pragma mark UITextViewDelegate
+#pragma mark SSViewController
-- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text {
- if (range.location == [textView.text length] - 1) {
- [_scrollView scrollRectToVisible:CGRectMake(0.0f, _scrollView.contentSize.height, 320.0f, 1.0f) animated:YES];
- }
+- (void)layoutViewsWithOrientation:(UIInterfaceOrientation)orientation {
- return YES;
+ CGSize size = [[UIScreen mainScreen] boundsForOrientation:orientation].size;
+ BOOL landscape = UIInterfaceOrientationIsLandscape(orientation);
+ size.height -= landscape ? 214.0f : 280.0f;
+
+ _scrollView.frame = CGRectMake(0.0f, 0.0f, size.width, size.height - 10.0f);
+}
+
+
+#pragma mark Getters
+
+- (SSRatingPicker *)ratingPicker {
+ return _scrollView.ratingPicker;
+}
+
+
+- (SSTextField *)titleTextField {
+ return _scrollView.titleTextField;
}
-- (void)textViewDidChange:(UITextView *)textView {
- CGFloat height = [textView sizeThatFits:CGSizeMake(_scrollView.frame.size.width, 2000.0f)].height + 91.0f;
- height = fmax(height, 191.0f);
- _scrollView.contentSize = CGSizeMake(320.0f, height);
- _reviewTextView.frame = CGRectSetHeight(_reviewTextView.frame, height - 91.0f);
+- (SSTextView *)reviewTextField {
+ return _scrollView.reviewTextField;
}
@end
View
14 SSToolkit/UIScreen+SSToolkitAdditions.h
@@ -0,0 +1,14 @@
+//
+// UIScreen+SSToolkitAdditions.h
+// SSToolkit
+//
+// Created by Sam Soffes on 2/4/11.
+// Copyright 2011 Sam Soffes. All rights reserved.
+//
+
+@interface UIScreen (SSToolkitAdditions)
+
+- (CGRect)currentBounds;
+- (CGRect)boundsForOrientation:(UIInterfaceOrientation)orientation;
+
+@end
View
30 SSToolkit/UIScreen+SSToolkitAdditions.m
@@ -0,0 +1,30 @@
+//
+// UIScreen+SSToolkitAdditions.m
+// SSToolkit
+//
+// Created by Sam Soffes on 2/4/11.
+// Copyright 2011 Sam Soffes. All rights reserved.
+//
+
+#import "UIScreen+SSToolkitAdditions.h"
+
+@implementation UIScreen (SSToolkitAdditions)
+
+- (CGRect)currentBounds {
+ return [self boundsForOrientation:[[UIDevice currentDevice] orientation]];
+}
+
+
+- (CGRect)boundsForOrientation:(UIInterfaceOrientation)orientation {
+ CGRect bounds = [self bounds];
+
+ if (UIInterfaceOrientationIsLandscape(orientation)) {
+ CGFloat buffer = bounds.size.width;
+
+ bounds.size.width = bounds.size.height;
+ bounds.size.height = buffer;
+ }
+ return bounds;
+}
+
+@end

0 comments on commit 3c163ec

Please sign in to comment.