1

I thought that it is going to be an easy thing but I am stuck with scrolling. Height of my UIScrollView is equal to the hight sets in my code (700) . I ticked off Use Autolayout. And it scrolls but do not show fully text UITextView . It is non-editable text, just description of town. It is a large text. I want to make some autofix for UIScrollView according to the long of the UITextView. Don`t want free space at the end of UITextView.

Thank you

Right now it looks something like this: 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
Milan1111
  • 185
  • 3
  • 13
  • 2
    Why have created scroll view your text view can make text scrollable – Inder Kumar Rathore Feb 01 '14 at 22:14
  • Because of I need to display here some Labels, UIImageViews, some Description via UITextView and I want to have it all in one scrollview – Milan1111 Feb 01 '14 at 22:16
  • If you want your scroll view scroll so that everything fits and there shouldn't be empty space at the end the you have to calculate the total height which is height of all your components + margin between them. Now how you calculate the variable text view size is [here](http://stackoverflow.com/q/18368567/468724) – Inder Kumar Rathore Feb 01 '14 at 22:22
  • Thank you for reply. I am gonna take a look at this. – Milan1111 Feb 01 '14 at 22:24
  • Still don`t understand how do you mean it. Because there are just samples for UITableView. Can you give me some examples? Thank you – Milan1111 Feb 01 '14 at 22:46

1 Answers1

0

It is a wrong way! you have to put inside your view in a interface all you need, but you have to use a little trick:

1) open your interface and put your UIScrollView

enter image description here

2) inside a UIScrollView put a UIImageView

enter image description here

3) under your image put your text inside a UILabel (I know is strange, but is a best and fast way to do wath you want)

enter image description here enter image description here

4) follow my screen i made for you ;)

enter image description here

To fix Scroll and Text manually follow the screen below 1) Here is normal view on interface builder

Here is normal view on interface builder

2) Now set a free form for you 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)

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

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

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

Hope this help you!

BlackSheep
  • 1,087
  • 12
  • 29
  • First of all thank you for your advice. On the other hand I am still in trouble, because it does not autofix by the long on text, which is in label. Any ideas how to do it? thank you – Milan1111 Feb 02 '14 at 13:56
  • With my method you have ti fix manually. add new screen on my answer ;) – BlackSheep Feb 02 '14 at 14:31
  • I think you missunderstood what I want. You think that I have some viewcontroller, where I have to display text, which have for example 16lines. But I have Tableview with segue to Detailviewcontroller and theres some data, description of town. And every town, every cell in my table view have different long of text. One has 20lines and other one has 40. I just want to fix the scrollview and don`t want any free spaces under text(I have it under the one with 20lines). – Milan1111 Feb 02 '14 at 14:53
  • I tried it by your tutorial and it fixed my problem with scrolling but have the free scape under the text, so it doesn`t cut it according to the long of text. – Milan1111 Feb 02 '14 at 14:54