English 中文(简体)
Buttons在躲藏航道时流离失所/分裂(After Rotation)
原标题:Buttons displaced/distorted when hiding the navigation bar (After Rotation)

我的申请有2名与导航管理员有联系的视线员。 第一航仓有一对 but,一对标签。 这是一种循环轮流的菜单,是我的家页。 这些意见可以与CGAffine TransformMakeRotation - QuartzCore(显然造成这一问题)轮流处理:

我只想在这种观点中掩盖航海,因此我使用了setNavigation BarHidden:YES <>em>ViewWillAppear。 然后在 意见书上注明。

在模拟器上,所有工作都按预期进行,直到第一次观察台轮换,当时我轮流点击了任何纽顿(第二次观察台),然后点击背(回头看我的第一位观察员),所有工作都将是stored

  1. I tried to fix the issue by adding [self.view setBounds:[[UIScreen mainScreen]bounds]]; *[self.view setFrame:[[UIScreen mainScreen]bounds]];* in ViewDidLoad method or ViweWillAppear, the issue remains.
  2. I tried to set NavigationBar alpha to 0 in ViewWillAppear and set it to 1 on ViewWillDisappear and I tried self.navigationController.navigationBar.translucent = YES both options didn t resolve the problem.
  3. I tried to set programmatically views, buttons and labels positions in ViewWillAppear and it doesn t resolve the problem.
  4. I doubted the animation so I removed it but it hasn t any effect on the problem.

As a beginner I m unable to resolve this issue, please help!

ViewController.h (first ViewController)

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@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

www.un.org/Depts/DGACM/index_french.htm

#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 
",self.aView.frame.origin.x, self.aView.frame.origin.y);
    printf("Aview width: %f | Aview height: %f 
",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];
 }
最佳回答

Yeah, I figured out the problem… The autoresize of the main View was squeezing my subviews when the NavigationController is hidden or not. so i added self.view.autoresizesSubviews = NO; to ViewDidLoad and the problem is fixed.

问题回答

暂无回答




相关问题
WPF Rotate 3D sphere to arbitratry position

If I have a sphere that is being rotate by the users mouse, how could I (at any time, say via a button) apply some rotation transformation on the Camera so that a specific spot on the Sphere is facing ...

Table View rotate, but not properly (shape change)

Here is the thing. I have a ViewController which contain a view in full window. And the program run in landscape mode. I want to put an UITableView over the full screen view but only on right half ...

How to rotate an object in C# 3D?

I need to rotate an 3D mesh object on an axis in C#. Could you show me how this is done?

Any free polygon library for the iPhone?

I need a library that can manage polygon modeling and basic transformation like rotating and translating. I d rather not redevelop everything from scratch Thanks

WPF 3d rotation animations

I have a few 3d rectangles on my screen that I want to pivot around the Y axis. I want to press down with the mouse, and rotate the 3d object to a max rotation, but when the user moves their mouse, ...

In Place rotation C++ Practice

I have a working rotating function going for my "items" int array. The code below gets it done, except that im transferring values out unnecessarily. Im trying to acheive the "inplace" rotation. What ...

iPhone: Draw rotated text?

I want to draw some text in a view, rotated 90°. I m pretty new to iPhone development, and poking around the web reveals a number of different solutions. I ve tried a few and usually end up with my ...

热门标签