Git Product home page Git Product logo

Comments (6)

lexiaoyao20 avatar lexiaoyao20 commented on July 21, 2024

Can you show me your full code?
I have updated the demo code,in file of CustomerViewController.m,but did not encounter the problem you said.

My english is poor, I do't know if you can understand what I said.

from fmtagsview.

albert0m avatar albert0m commented on July 21, 2024

your english is fine, don't worry!

My problem is that I need to resize the frame after I draw the tags because I don't know the number of tags and probably is more or less than the initial given size (in your example the height is 190). I programmatically put the tagView in a scrollView and after drawing the tagView, the height is too much and it doesn't resize.

This is what happens:
schermata 2017-07-27 alle 11 58 17

how can I make the view resize after I draw it and fit the real used height?

Thank you

from fmtagsview.

lexiaoyao20 avatar lexiaoyao20 commented on July 21, 2024

It's my control's bug. You must set the tagsView with the correct width.

- (FMTagsView *)createTagsViewWithDataSrouse:(NSArray *)dataSource borderColor:(UIColor *)borderColor {
    CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
    CGFloat padding = 15;
    //must set the correct width
    FMTagsView *tagsView = [[FMTagsView alloc] initWithFrame:CGRectMake(0, 0, screenWidth - padding * 2, 180)];
    tagsView.backgroundColor = [UIColor whiteColor];
    tagsView.delegate = self;
    tagsView.contentInsets = UIEdgeInsetsMake(10, 10, 10, 10);
    tagsView.tagcornerRadius = 0;
    tagsView.layer.borderColor = borderColor.CGColor;
    tagsView.layer.borderWidth = 1;
    tagsView.tagsArray = dataSource;
    
    return tagsView;
}

2017-07-27 7 24 59

The code has been updated, wish to help you.

from fmtagsview.

albert0m avatar albert0m commented on July 21, 2024

so basically the magic happens because of the Costraints part. I commented a piece of your code and this is what I had already reported at the beginning:

schermata 2017-08-21 alle 17 00 05

The tagview height is exactly 180 like configured at the beginning.
Is there any way to set the constraints dynamically?? I'm working with dynamic zones and I don't have label1, label2, label3.. Sorry but I'm very new to objective c and constraints are still really hard to understand.

What if I didn't use constraints? how can I resize the view without those?

from fmtagsview.

lexiaoyao20 avatar lexiaoyao20 commented on July 21, 2024

Becasue the scrollview's contentSize is determined by its internal subviews, in my code, the scrollContentView's size is determined by its subviews, and the scrollView's contentSize is determined by the scrollCotentView.

[self.scrollContentView mas_makeConstraints:^(MASConstraintMaker *make){
        make.bottom.equalTo(self.tagsView3.mas_bottom).offset(10);
    }];

I have add a new method called changeDataSource in my latest code, this change the tagsview's height dynamically, As shown below:

autolayout

I recommend you some information to learn Autolayout:

  1. Using UIScrollView with Auto Layout in iOS
  2. AutolayoutExampleWithMasonry
  3. Beginning Auto Layout Tutorial in iOS 7: Part 1
  4. Beginning Auto Layout Tutorial in iOS 7: Part 2

from fmtagsview.

albert0m avatar albert0m commented on July 21, 2024

thank you so much for your help! since I dynamically created the views, I ended up doing something as simple as this:

`for (int x =0;x<arrayView.count;x++) {

                            if (x-1>=0) {

                                UIView *previousView = arrayView[(NSUInteger) (x-1)];
                                UIView *currentView = arrayView[(NSUInteger) (x)];
                                [currentView mas_makeConstraints:^(MASConstraintMaker *make){
                                    make.top.equalTo(previousView.mas_bottom).offset(15);
                                    make.left.equalTo(previousView);
                                }];
                            }

                        }`

not sure if there is any better way to achieve this, but this is good as a beginning!

from fmtagsview.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.