android+虚拟导航栏引起位移,隐藏导航栏时位移/扭曲的按钮(旋转后)

我的应用程序有两个ViewController与NavigationController链接。第一个NavigationController有一个带按钮的视图和一个带标签的视图。这个视图是一个循环旋转菜单,它代表了我的主页。视图可以随CGAffineTransformMakeRotation旋转 - QuartzCore(显然这是造成问题)在touchesMoved :.隐藏导航栏时位移/扭曲的按钮(旋转后)

我想隐藏导航栏只有在这种观点,所以我用setNavigationBarHidden:YES上viewWillAppear中。然后在ViewWillDisappear上显示吧。

在模拟器上,一切按预期工作,直到我旋转第一个ViewController,当我旋转然后点击任何按钮(转到第二个ViewController)然后点击返回(回到我的第一个ViewController),一切都会是distorted!

我试图通过添加来解决该问题[self.view的setBounds:[[UIScreen mainScreen]界限]]; * [self.view SETFRAME:[[UIScreen mainScreen]界限]]; *在viewDidLoad中方法或ViweWillAppear, 问题仍然存在。

我试图导航栏阿尔法在viewWillAppear中设置为0和设置 它1 ViewWillDisappear,我试图 self.navigationController.navigationBar.translucent = YES都 选项并没有解决问题。

我试图以编程方式设置视图,按钮和标签的位置 in ViewWillAppear并且它不能解决问题。

我怀疑动画,所以我删除它,但它对问题没有任何影响。

作为初学者,我无法解决此问题,请帮忙!

ViewController.h(第一视图控制器)

#import

#import

@interface ViewController : UIViewController

@property (nonatomic, strong) IBOutlet UIView *aView;

@property (nonatomic, strong) IBOutlet UIView *bView;

@property (nonatomic, strong) IBOutlet UIButton *bimg1;

@property (strong, nonatomic) IBOutlet UILabel *label1;

-(void) rotateTo:(CGFloat)x andY:(CGFloat)y;

@end

ViewController.m

#import "ViewController.h"

@implementation ViewController

@synthesize aView = _aView;

@synthesize bimg1 = _bimg1;

@synthesize label1 = _label1;

static inline double toradians (double degrees) {

return degrees * M_PI/180;

}

-(void)viewDidLoad {

![enter image description here][1][super viewDidLoad];

//Set text font

[_label1 setFont:[UIFont fontWithName:@"Consolas" size:16]];

[self.view setBounds:[[UIScreen mainScreen]bounds]];

[self.view setFrame:[[UIScreen mainScreen]bounds]];

}

-(void)viewWillAppear:(BOOL)animated {

self.navigationController.navigationBar.hidden = YES;

printf("Aview x: %f | Aview y: %f \n",self.aView.frame.origin.x, self.aView.frame.origin.y);

printf("Aview width: %f | Aview height: %f \n",self.aView.frame.size.width, self.aView.frame.size.height);

}

-(void)viewWillDisappear:(BOOL)animated {

self.navigationController.navigationBar.hidden = NO;

}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

UITouch *touch = [touches anyObject];

CGPoint LastTouchPoint = [touch locationInView:self.view];

CGFloat LasTouchx = LastTouchPoint.x;

CGFloat LasTouchy = LastTouchPoint.y;

CGPoint CenterPoint = self.view.center;

CGFloat x = LasTouchx - CenterPoint.x;

[self rotateTo:x andY:y];

}

-(void) rotateTo:(CGFloat)x andY:(CGFloat)y {

CGFloat angle = x/y;

angle = atan(angle);

angle = angle * 360/M_PI;

angle *= 0.0174532925;

[UIView beginAnimations:nil context:nil];

[UIView setAnimationDelegate:self];

[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

[UIView setAnimationDuration:1];

self.aView.transform=CGAffineTransformMakeRotation(-angle);

self.bView.transform=CGAffineTransformMakeRotation(-angle);

self.bimg1.transform=CGAffineTransformMakeRotation(angle);

self.bimg2.transform=CGAffineTransformMakeRotation(angle);

self.bimg3.transform=CGAffineTransformMakeRotation(angle);

self.bimg4.transform=CGAffineTransformMakeRotation(angle);

self.label1.transform=CGAffineTransformMakeRotation(angle);

self.label2.transform=CGAffineTransformMakeRotation(angle);

self.label3.transform=CGAffineTransformMakeRotation(angle);

self.label4.transform=CGAffineTransformMakeRotation(angle);

[UIView commitAnimations];

}

- (void)viewDidUnload

{

[self setBimg1:nil];

[self setAView:nil];

[self setBView:nil];

[super viewDidUnload];

}

+0

我注意到,虽然从第一个ViewController翻译到第二个,第一个视图延伸(显然NavigationBar是挤压视图)!它仍然被挤压!...任何想法如何避免这种情况?每次我去第二个ViewController并回到第一个时,它会挤压更多... –

2012-04-19 14:32:11

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值