小编use*_*279的帖子

文本太大时,文本不显示在UILabel上.

我有一个文本(一本书的故事).我正在拿UILabel来展示它.但它没有让我看到.我使用以下代码:

    CGSize labelsize;
    UILabel *commentsTextLabel = [[UILabel alloc] init];;
    [commentsTextLabel setNumberOfLines:0];
    commentsTextLabel.textColor = [UIColor blackColor];
    [commentsTextLabel setBackgroundColor:[UIColor clearColor]];
    [commentsTextLabel setFont:[UIFont fontWithName:@"ACaslonPro-Regular"size:17]];
    labelsize=[story sizeWithFont:commentsTextLabel.font constrainedToSize:CGSizeMake(280, 15000) lineBreakMode:NSLineBreakByWordWrapping];
    commentsTextLabel.frame=CGRectMake(20, 200, 280, labelsize.height);
   commentsTextLabel.text = story;// more than 1000 lines

   [self.view addSubview:commentsTextLabel];
Run Code Online (Sandbox Code Playgroud)

当我调试我的代码时,我发现labelize.height出现在我的情况下13145.Still它没有显示.如果我减少15000到11000,那么文本最终会显示在....

labelsize = [story sizeWithFont:commentsTextLabel.font constrainedToSize:CGSizeMake(280,15000)lineBreakMode:NSLineBreakByWordWrapping];

请帮帮我.谢谢

iphone objective-c uilabel ios

8
推荐指数
2
解决办法
7573
查看次数

全局队列中的计时器未在iOS中调用

-(void)viewDidLoad{
    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
        [NSTimer scheduledTimerWithTimeInterval:0.10 
                                         target:self 
                                       selector:@selector(action_Timer) 
                                       userInfo:nil 
                                        repeats:YES];
        }
    );
}

-(void)action_Timer{
    LOG("Timer called");
}
Run Code Online (Sandbox Code Playgroud)

action_Timer没有被召唤.我不知道为什么.你有什么主意吗?

iphone nstimer grand-central-dispatch ios

5
推荐指数
1
解决办法
3470
查看次数