Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/93.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
uitextview文本显示在ios 7上,但不显示在ios 6上_Ios_Iphone_Objective C - Fatal编程技术网

uitextview文本显示在ios 7上,但不显示在ios 6上

uitextview文本显示在ios 7上,但不显示在ios 6上,ios,iphone,objective-c,Ios,Iphone,Objective C,我在uiscrollview上以编程方式添加了多个uitextfields,它工作正常,并在ios 7中显示文本。但我在ios 6上遇到了一个问题,它不显示文本,它只是在uiscrollview上显示一个黑色背景的大空白区域。这就是代码 // set array values to label -(void)addTextViews:(NSArray *)qualArray { //adding qualification label UILabel *qualLbl; if

我在uiscrollview上以编程方式添加了多个uitextfields,它工作正常,并在ios 7中显示文本。但我在ios 6上遇到了一个问题,它不显示文本,它只是在uiscrollview上显示一个黑色背景的大空白区域。这就是代码

// set array values to label
-(void)addTextViews:(NSArray *)qualArray
{
   //adding qualification label
   UILabel *qualLbl;
   if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
   {
        qualLbl = [[UILabel alloc]initWithFrame:CGRectMake(10, imgVw.bounds.size.height+20, 100, 20)];
        [qualLbl setFont:[UIFont boldSystemFontOfSize:14.0]];
   }
   else
         qualLbl = [[UILabel alloc]initWithFrame:CGRectMake(10, imgVw.bounds.size.height+20, 150, 20)];
     [qualLbl setFont:[UIFont boldSystemFontOfSize:20.0]];
   }

    [qualLbl setTextColor:[UIColor colorWithRed:226.0f/255.0f green:73.0f/255.0f blue:20.0f/255.0f alpha:1.0]];
    [qualLbl setBackgroundColor:[UIColor clearColor]];
    [qualLbl setText:@"Qualification"];
    [self.srcVw addSubview:qualLbl];
    // adding text views
   NSLog(@"img view height %f",imgVw.bounds.size.height);
   height = imgVw.bounds.size.height + 55;

    for (int i = 0; i < qualArray.count ; i++) {
        UITextView *txtVw ;
        UILabel *symbolLabel;
        if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
        {
            txtVw =[[UITextView alloc]initWithFrame:CGRectMake(35, height, self.srcVw.bounds.size.width-50, 0)];
            [txtVw setFont:[UIFont systemFontOfSize:12.0]];

            symbolLabel =[[UILabel alloc]initWithFrame:CGRectMake(10, height, 25, 25)];
            [symbolLabel setFont:[UIFont systemFontOfSize:12.0]];
        }
        else
        {
            txtVw =[[UITextView alloc]initWithFrame:CGRectMake(35, height, self.srcVw.bounds.size.width-50, 0)];
            [txtVw setFont:[UIFont systemFontOfSize:20.0]];

            symbolLabel =[[UILabel alloc]initWithFrame:CGRectMake(10, height, 25, 25)];
            [symbolLabel setFont:[UIFont systemFontOfSize:12.0]];
        }

        [txtVw setScrollEnabled:NO];
        [txtVw setEditable:NO];
        [txtVw  setText:[NSString stringWithFormat:@"%@" ,[qualArray objectAtIndex:i]]];
        [txtVw sizeToFit];
        [txtVw setTextColor:[UIColor whiteColor]];
        [txtVw setBackgroundColor:[UIColor clearColor]];

        [self.srcVw addSubview:txtVw];
        //  [txtVw setContentMode:UIViewContentModeScaleAspectFit];
        //setting symbol label properties
        [symbolLabel  setText:@">"];
        [symbolLabel setBackgroundColor:[UIColor clearColor]];
        [symbolLabel setTextColor:[UIColor colorWithRed:226.0f/255.0f green:73.0f/255.0f blue:20.0f/255.0f alpha:1.0]];
        [self.srcVw addSubview:symbolLabel];
        height = height + txtVw.frame.size.height;
    }
}
//将数组值设置为标签
-(无效)添加文本视图:(NSArray*)qualArray
{
//添加资格标签
UILabel*qualLbl;
如果(用户界面习惯用法()==UIUserInterfaceIdiomPhone)
{
qualLbl=[[UILabel alloc]initWithFrame:CGRectMake(10,imgVw.bounds.size.height+20100,20)];
[qualLbl setFont:[UIFont boldSystemFontOfSize:14.0]];
}
其他的
qualLbl=[[UILabel alloc]initWithFrame:CGRectMake(10,imgVw.bounds.size.height+2015020)];
[qualLbl setFont:[UIFont boldSystemFontOfSize:20.0]];
}
[qualLbl setTextColor:[UIColor COLOR WITH RED:226.0f/255.0f green:73.0f/255.0f blue:20.0f/255.0f alpha:1.0];
[qualLbl setBackgroundColor:[UIColor clearColor]];
[qualLbl setText:@“资格”];
[self.srcVw addSubview:qualbl];
//添加文本视图
NSLog(@“img视图高度%f”,imgVw.bounds.size.height);
高度=imgVw.bounds.size.height+55;
for(int i=0;i”];
[symbolLabel setBackgroundColor:[UIColor clearColor]];
[symbolLabel setTextColor:[UIColor COLOR WITH RED:226.0f/255.0f green:73.0f/255.0f blue:20.0f/255.0f alpha:1.0];
[self.srcVw addSubview:symbolLabel];
高度=高度+txtVw.frame.size.height;
}
}

它的代码在ios 7中运行得非常完美,但我不知道在ios 6上运行它时会出现什么问题

您已将uitextview的高度设置为零(0)

把它改成30

txtVw =[[UITextView alloc]initWithFrame:CGRectMake(35, height, self.srcVw.bounds.size.width-50, 30)];

因为在iOS 7中,它采用默认大小,但在iOS 6中,它不采用默认值。

最好的做法是在没有使用自动布局的情况下更改界面生成器中的增量。

我想知道,因为您的qualArray可以包含多个元素,为什么要在每个循环的同一位置添加txtVw和symbolLabel?我怀疑问题似乎是[txtVw setTextColor:[UIColor whiteColor]],因为默认情况下textview的背景是白色的,而您正在以白色渲染文本。我已经设置了[txtVw setBackgroundColor:[UIColor clearColor];我还告诉过你,它在iOS7模拟器上运行得非常好
txtVw =[[UITextView alloc]initWithFrame:CGRectMake(35, height, self.srcVw.bounds.size.width-50, 30)];