1

appDelegate.mはこのコードを持っていますが、UILabelは表示されず、UIImageView.

なんで?

notificationView = [[UIImageView alloc] initWithFrame: CGRectMake(154, 320, 140, 47)];
notificationView.image = [UIImage imageNamed:@"notification.png"];

NSString *message = [NSString stringWithString:@"New Videos"];

notificationLabel = [[UILabel alloc] initWithFrame: CGRectMake(165, 313, 140, 47)]; 
notificationLabel.font = [UIFont boldSystemFontOfSize:12];
notificationLabel.textAlignment = UITextAlignmentLeft;
notificationLabel.text = [NSString stringWithFormat:@"%d %@", numberOfVideos, message];
notificationLabel.textColor = [UIColor whiteColor];
notificationLabel.backgroundColor = [UIColor clearColor];

notificationView.alpha = 0.0;
notificationLabel.alpha = 0.0;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.5];
notificationView.alpha = 1.0;
notificationLabel.alpha = 1.0;
[UIView commitAnimations];

[self.window addSubview: notificationView];
[self.notificationView addSubview: notificationLabel];

[UIView commitAnimations];  

[notificationView release];
[notificationLabel release];
4

2 に答える 2

5

notificationLabel は、notificationView のサブビューです。スーパービューの範囲外に配置されています。

試す

notificationLabel = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, 140, 47)]; 

そしてそこから行きます。すべてのサブビューで、スーパー ビューの左上隅は (0, 0) です。

于 2012-06-27T16:20:21.890 に答える
4

通知ビューの幅は です140。ラベルは165、通知ビューの範囲外にある通知ビュー内の X 位置に配置されています。だから見えない。

于 2012-06-27T16:06:37.140 に答える