小蚂蚁威小威 2014-09-21 07:34 采纳率: 50%
浏览 6623
已采纳

Xcode 6 我用代码改变storyboard的控件的frame值为何无法成功,菜鸟新手求大神指点

#import "ViewController.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UIButton *btn;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"%f %f %f %f",_btn.frame.origin.x,_btn.frame.origin.y,_btn.frame.size.height,_btn.frame.size.width);
    _btn.frame = CGRectMake(20, 20, 280, 280);
    NSLog(@"%f %f %f %f",_btn.frame.origin.x,_btn.frame.origin.y,_btn.frame.size.height,_btn.frame.size.width);
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

在运行后 输出结果为:

2014-09-21 15:25:34.779 test[2473:80334] 20.000000 20.000000 30.000000 30.000000
2014-09-21 15:25:34.784 test[2473:80334] 20.000000 20.000000 30.000000 30.000000
  • 写回答

5条回答

  • NXAristotle 2014-10-11 04:30
    关注

    Xcode6默认是勾选这两项的,去掉才能有效.不过,以后屏幕多了,用自动布局来适配屏幕是大势所趋,再用代码来适配将会是场噩梦,建议还是习惯用autolayout+sizeclasses适配屏幕CSDN移动问答

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序