Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 标签旋转出错_Iphone_Objective C_Rotation_Label - Fatal编程技术网

Iphone 标签旋转出错

Iphone 标签旋转出错,iphone,objective-c,rotation,label,Iphone,Objective C,Rotation,Label,我想这样做: 在我的故事板中,我放置了如下标签: 每个标签为70宽20高 标签的名称为: label1 (position x:20 y:161) label2 (position x:50 y:161) label3 (position x:80 y:161) label4 (position x:110 y:161) label5 (position x:140 y:161) label6 (position x:170 y:161) label7 (position x:200 y:161

我想这样做:

在我的故事板中,我放置了如下标签:

每个标签为70宽20高

标签的名称为:

label1 (position x:20 y:161)
label2 (position x:50 y:161)
label3 (position x:80 y:161)
label4 (position x:110 y:161)
label5 (position x:140 y:161)
label6 (position x:170 y:161)
label7 (position x:200 y:161)
label8 (position x:230 y:161)
label9 (position x:260 y:161)
label10 (position x:290 y:161)
在my ViewController.h中:

@property (strong, nonatomic) IBOutlet UILabel *label1;
@property (strong, nonatomic) IBOutlet UILabel *label2;
@property (strong, nonatomic) IBOutlet UILabel *label3;
@property (strong, nonatomic) IBOutlet UILabel *label4;
@property (strong, nonatomic) IBOutlet UILabel *label5;
@property (strong, nonatomic) IBOutlet UILabel *label6;
@property (strong, nonatomic) IBOutlet UILabel *label7;
@property (strong, nonatomic) IBOutlet UILabel *label8;
@property (strong, nonatomic) IBOutlet UILabel *label9;
@property (strong, nonatomic) IBOutlet UILabel *label10;
在ViewDidLoad方法的my ViewController.m中:

[label1 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label2 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label3 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label4 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label5 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label6 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label7 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label8 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label9 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
[label10 setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
但当我运行模拟器时,出现了一些问题:

前五个标签可以,但其他五个标签处于随机位置


如何解决此问题?

在IB中,从包含所有标签的superview开始。将标签放置在包含superview的标签中,从上到下堆叠,左对齐。。。如果它们不旋转,你会看到什么

设置包含superview的插座,并对其应用单个
-M_PI/2
变换。

使用以下代码:

label1.transform = CGAffineTransformMakeRotation(DegreesToRadians(270));
等等

还定义

定义度弧度(x)((x)*M_PI/180.0)
有了你的解决方案,问题不会消失