UIScrollView中的UITextView没有到达最终位置

时间:2014-02-01 22:12:16

标签: ios uiscrollview uitextview parse-platform

我认为这将是一件容易的事,但我仍然坚持滚动。我的UIScrollView的高度等于我的代码中的高度集(700)。我勾选了Use Autolayout。它滚动但不显示完整文本UITextView。这是不可编辑的文字,只是对城镇的描述。这是一个大文本。我想根据UIScrollView的长度为UITextView制作一些自动修复功能。不要在UITextView末尾有空闲空间。

谢谢

现在它看起来像这样: enter image description here

DetailViewController.h

#import <UIKit/UIKit.h>
#import "Parse/Parse.h"
#import "TableViewController.h"

@interface DetailViewController : UIViewController <  UITextFieldDelegate, UITextViewDelegate, UIScrollViewDelegate>


@property (strong, nonatomic) IBOutlet UITextView *PopisMesta;
@property (nonatomic, strong) PFObject *detailItem;
@property (nonatomic,strong) IBOutlet UILabel *deatailedlabel;
@property (nonatomic, strong) IBOutlet UILabel *pocetobyv;
@property (strong, nonatomic) IBOutlet UIImageView *imageviewsec;
@property (strong, nonatomic) IBOutlet UIScrollView *viewScroller;

@end

DetailViewController.m

#import "DetailViewController.h"
#import "Parse/Parse.h"
#import <SDWebImage/UIImageView+WebCache.h>

@interface DetailViewController ()

@end

@implementation DetailViewController

@synthesize PopisMesta;
@synthesize deatailedlabel;
@synthesize pocetobyv;
@synthesize imageviewsec;
@synthesize viewScroller;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{


    [viewScroller setScrollEnabled:YES];
    [viewScroller setContentSize:CGSizeMake(320, 700)];

    self.PopisMesta.text = [self.detailItem objectForKey:@"PopisMesta"];


    self.deatailedlabel.text = [self.detailItem objectForKey:@"MestoName"];


    self.pocetobyv.text = [self.detailItem objectForKey:@"PocetObyv"];


    [self.imageviewsec setImageWithURL:[NSURL URLWithString:[self.detailItem objectForKey:@"ImageURL"]]
                    placeholderImage:[UIImage imageNamed:@"placeholder.png"]];






}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

1 个答案:

答案 0 :(得分:0)

这是一种错误的方式!你必须在你想要的界面中放入你的视图,但你必须使用一个小技巧:

1)打开界面并放置UIScrollView

enter image description here

2)在UIScrollView内放置UIImageView

enter image description here

3)在你的形象下把你的文字放在UILabel里面(我知道这很奇怪,但这是一种你想要的最快捷的方式)

enter image description here enter image description here

4)按照我为你制作的屏幕;)

enter image description here

要手动修改滚动和文字,请按照以下屏幕 1)以下是界面构建器的正常视图

Here is normal view on interface builder

2)现在为你设置一个自由形式的ViewController

Now set a free form for you ViewController

3)转到大小并设置你想要的长度(在滚动视图中查看所有内容)

Go to size and set what you want long (to see all inside a scroll view)

4)这是一个结果,设置你想要的和重制后的viewController 568高度

This is a result, set what you want and after remake viewController a 568 Height

希望这对你有帮助!