Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

replyview interface rotation

  • Loading branch information...
commit cc9a92aa79accdd0bd48d4bc606972c77b3558c3 1 parent dd7e2c0
@han9kin authored
Showing with 46 additions and 27 deletions.
  1. +37 −19 Classes/MEReplyViewController.m
  2. +9 −8 ReplyView.xib
View
56 Classes/MEReplyViewController.m
@@ -15,6 +15,34 @@
#import "MEComment.h"
+@interface MEReplyViewController (Private)
+@end
+
+@implementation MEReplyViewController (Private)
+
+- (void)layoutViewsForInterfaceOrientation:(UIInterfaceOrientation)aInterfaceOrientation
+{
+ switch (aInterfaceOrientation)
+ {
+ case UIInterfaceOrientationLandscapeLeft:
+ case UIInterfaceOrientationLandscapeRight:
+ [mNavigationBar setFrame:CGRectMake(0, 0, 480, 32)];
+ [mTextView setFrame:CGRectMake(0, 32, 480, 76)];
+ [mCounterLabel setFrame:CGRectMake(370, 108, 100, 30)];
+ break;
+
+ case UIInterfaceOrientationPortrait:
+ case UIInterfaceOrientationPortraitUpsideDown:
+ [mNavigationBar setFrame:CGRectMake(0, 0, 320, 44)];
+ [mTextView setFrame:CGRectMake(0, 44, 320, 170)];
+ [mCounterLabel setFrame:CGRectMake(210, 214, 100, 30)];
+ break;
+ }
+}
+
+@end
+
+
@implementation MEReplyViewController
@@ -70,8 +98,12 @@ - (void)viewDidLoad
{
[super viewDidLoad];
+ [self layoutViewsForInterfaceOrientation:[[UIApplication sharedApplication] statusBarOrientation]];
+
[mTextView setText:mText];
[mTextView becomeFirstResponder];
+
+ [mCounterLabel setText:[NSString stringWithFormat:@"%d", (kMECommentBodyMaxLen - [[mTextView text] length])]];
}
@@ -81,26 +113,12 @@ - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)aInterfac
}
-- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)aFromInterfaceOrientation
+- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)aInterfaceOrientation duration:(NSTimeInterval)aDuration
{
- UIInterfaceOrientation sOrientation;
- CGRect sFrame;
-
- [mNavigationBar sizeToFit];
- sFrame = [mNavigationBar frame];
- sOrientation = [self interfaceOrientation];
-
- if (sOrientation == UIInterfaceOrientationPortrait || sOrientation == UIInterfaceOrientationPortraitUpsideDown)
- {
- [mTextView setFrame:CGRectMake(0, sFrame.origin.y + sFrame.size.height, sFrame.size.width, 200)];
- }
- else if (sOrientation == UIInterfaceOrientationLandscapeLeft || sOrientation == UIInterfaceOrientationLandscapeRight)
- {
- [mTextView setFrame:CGRectMake(0, sFrame.origin.y + sFrame.size.height, sFrame.size.width, 106)];
- }
-
- sFrame = [mTextView frame];
- [mCounterLabel setFrame:CGRectMake(sFrame.origin.x + sFrame.size.width - 60, sFrame.origin.y + sFrame.size.height - 40, 60, 40)];
+ [UIView beginAnimations:nil context:NULL];
+ [UIView setAnimationDuration:aDuration];
+ [self layoutViewsForInterfaceOrientation:aInterfaceOrientation];
+ [UIView commitAnimations];
}
View
17 ReplyView.xib
@@ -38,7 +38,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUINavigationBar" id="732934088">
<reference key="NSNextResponder" ref="191373211"/>
- <int key="NSvFlags">290</int>
+ <int key="NSvFlags">256</int>
<string key="NSFrameSize">{320, 44}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
@@ -61,8 +61,8 @@
</object>
<object class="IBUITextView" id="887066987">
<reference key="NSNextResponder" ref="191373211"/>
- <int key="NSvFlags">274</int>
- <string key="NSFrame">{{0, 44}, {320, 179}}</string>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{0, 44}, {320, 170}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -78,16 +78,16 @@
</object>
<object class="IBUILabel" id="983942233">
<reference key="NSNextResponder" ref="191373211"/>
- <int key="NSvFlags">292</int>
- <string key="NSFrame">{{258, 198}, {53, 26}}</string>
+ <int key="NSvFlags">256</int>
+ <string key="NSFrame">{{210, 214}, {100, 30}}</string>
<reference key="NSSuperview" ref="191373211"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIUserInteractionEnabled">NO</bool>
- <string key="IBUIText">Label</string>
+ <string key="IBUIText">150</string>
<object class="NSFont" key="IBUIFont">
<string key="NSName">Helvetica-Bold</string>
- <double key="NSSize">3.000000e+01</double>
+ <double key="NSSize">2.400000e+01</double>
<int key="NSfFlags">16</int>
</object>
<object class="NSColor" key="IBUITextColor">
@@ -103,6 +103,7 @@
<bytes key="NSWhite">MCAwLjEzAA</bytes>
</object>
<int key="IBUIBaselineAdjustment">1</int>
+ <bool key="IBUIAdjustsFontSizeToFit">NO</bool>
<float key="IBUIMinimumFontSize">1.000000e+01</float>
<int key="IBUITextAlignment">2</int>
</object>
@@ -271,7 +272,7 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<string>MEReplyViewController</string>
<string>UIResponder</string>
- <string>{{371, 200}, {320, 460}}</string>
+ <string>{{147, 208}, {320, 460}}</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
Please sign in to comment.
Something went wrong with that request. Please try again.