Iphone 无法将UILabel添加到视图中

Iphone 无法将UILabel添加到视图中,iphone,Iphone,我试图添加一个UILabel,语法错误如下 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg"]]]; [s

我试图添加一个UILabel,语法错误如下

- (void)viewDidLoad 
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [self.view setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg"]]];

    [self loadAndDrawButtons];
    CGRect  frame       =   CGRectMake(357, 240, 48, 42);
    CGRect  frame       =   CGRectMake(357, 200, 48, 42);
    UILabel *myLabel    =   [[UILabel alloc] initWithFrame:frame];

    [myLabel setText:@"THIS"];
    [myLabel setBackgroundColor:[UIColor clearColor]];

    [myLabel setTextColor:[UIColor redColor]];

    [myLabel setShadowOffset:CGSizeMake(1, 1)];

    [myLabel setShadowColor:[UIColor darkGrayColor]];

    [self.view  addSubview:myLabel];
}
因此,首先我为视图设置背景,然后在视图上显示一些按钮。后台和按钮已成功加载。最终,我在视图中添加了一个UILabel,结果一无所获。。。。 我想背景和我的按钮会隐藏我的UILabel(我知道这不是正确的方法,但也尝试一下),这样我就可以发表评论了

//[self.view setBackgroundColor:[UIColor WithPatternImage:[UIImage ImageName:@“bg”]]

//[自动加载和绘图按钮]

现在我的视图是空白的,没有我的向导。。。
有谁能给我一个关于这个问题的提示…非常感谢

标签框中的问题如下:

CGRect frame = CGRectMake(357, 200, 48, 42);
这是相对于其superview坐标的。在这种情况下,您的视图最多为320 x 480(或者至少是屏幕在不滚动的情况下可以显示的数量),但是您提供的x值为357(大于320),这意味着标签未在视图的可见部分内绘制。

CGRect frame=CGRectMake(3572000,48,42)

357是标签的x原点。
Iphone的x方向限制为320。将其更改为低于320的值可能是因为您将框架设置在屏幕外?我假设这是Iphone应用程序,在纵向视图中,357肯定在屏幕外

试试这个吧

CGRect  frame = CGRectMake(180, 240, 48, 42);

是的,你是rite..我没有注意尺寸。当我做这个CGRect frame=CGRectMake(200,357,48,42);。UILabel已加载并显示。谢谢你的帮助