Ios 在uiScrollView之前添加uiTextView

Ios 在uiScrollView之前添加uiTextView,ios,uiscrollview,uitextfield,Ios,Uiscrollview,Uitextfield,我希望文本视图位于我的tablecell中的scrollview之前,就像这样,这样scrollview就会滚动,标题就会保持不变 [Title goes here] - it does not move with the scrollview --------------------- | | | ScrollView | | | --------------------- 这是我的代码,文本视图显示在滚动

我希望文本视图位于我的tablecell中的scrollview之前,就像这样,这样scrollview就会滚动,标题就会保持不变

[Title goes here] - it does not move with the scrollview
---------------------
|                   |
|    ScrollView     |
|                   |
---------------------
这是我的代码,文本视图显示在滚动视图后面。

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MainCell"];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"MainCell"];
    }

    NSInteger numberOfViews = 10;
    UIScrollView *vwScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 1280, 200)];

    for (int i = 0; i < numberOfViews; i++) {
        CGFloat xOrigin = i * 250;
        UITextView *titleView = [[UITextView alloc]  initWithFrame:CGRectMake(0, 0, 1280, 20)];
        titleView.text = @"Title";
        [titleView setFont:[UIFont fontWithName:@"HelveticaBold" size:32]];


        UIView *awesomeView = [[UIView alloc] initWithFrame:CGRectMake(xOrigin, 0, 250, 180)];
        awesomeView.backgroundColor = [UIColor colorWithRed:0.5/i green:0.5/i/10 blue:0.5 alpha:1];
        [awesomeView.layer setBorderColor:[UIColor whiteColor].CGColor];
        [awesomeView.layer setBorderWidth:10.5f];
        awesomeView.layer.shadowPath = [UIBezierPath bezierPathWithRect:awesomeView.bounds].CGPath;

        [cell.contentView addSubview:titleView];
        [vwScroll addSubview:awesomeView];

    }
    vwScroll.contentSize = CGSizeMake(250 * numberOfViews, 200);

    [cell.contentView addSubview:vwScroll];

    return cell;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell*单元格=[tableView dequeueReusableCellWithIdentifier:@“MainCell”];
如果(单元格==nil){
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault重用标识符:@“MainCell”];
}
NSInteger numberOfViews=10;
UIScrollView*vwcroll=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,1280,200)];
对于(int i=0;i
为什么不能将标题视图的边框设置为,比如说,
(0,0,宽度,标题亮度)
,然后将滚动视图的边框设置为
(0,标题亮度,宽度,单元格高度标题亮度)


这只会将标题放在单元格的顶部,将其高度设置为您所设置的标题灯的高度,并将滚动视图放在单元格的底部,将其高度设置为单元格的其余部分。

您是否将滚动视图的Y坐标设置为与textView的高度相同?啊,这就是问题所在!伙计,我没想过,谢谢,把它加到你的答案上,我会给你一个绿色标记:-)它在答案中:)在滚动视图框架的第二个坐标是
标题灯