GithubHelp home page GithubHelp logo

Comments (38)

sLm-s avatar sLm-s commented on May 11, 2024

And there is one more question. How to create such a layout, as in the picture? There are two texts that are always located at the edges opposite each other and between them the line.

simulator screen shot - iphone 8 - 2017-11-03 at 12 49 13

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

@lucdion I need your help. Error -- Module compiled with Swift 4.0 cannot be imported in Swift 4.0.2
in xCode 9.1

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

@sLm-s if you use carthage, delete your Carthage directory and reintall carthage modules. If you use pod, be sure to clean up everything before rebuilding (even sometimes the derived data directory).

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

For your problem above, sorry I didn't have the time yet to test it using flexbox.
Using PinLayout it would be:

redText.pin.left().vCenter().fitSize()
purpleText.pin.right().vCenter().fitSize()
lineView.pin.after(of: redText).before(of: purpleText).vCenter().marginHorizontal(10)

I'll test it using FlexLayout later today. Thanks

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

Thank you so much. I'll wait for the FlexLayut example. I do not use PinLayout.

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

@sLm-s, here is the solution to your layout:

           flex.addItem().direction(.row).padding(2, 6, 2, 6).backgroundColor(.cyan).define({ (flex) in
                flex.addItem(redLabel)
                flex.addItem(lineSeparator).height(3).grow(1).marginHorizontal(6).alignSelf(.center)
                flex.addItem(purpleLabel)
            })

screen shot 2017-11-06 at 10 34 25 am

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

@lucdion Thank you for helping me.

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

@lucdion Is it possible to change the width of an object, for example, if it was initially set to zero but after calculations 100. Excuse me for my obsession.

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

Yes, it should work if you do myView.flex.width(100) and then relayout the flex container.

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

override init(frame: CGRect) {
super.init(frame: frame)

    contentView.flex.addItem().direction(.row).paddingVertical(1).define({ (flex) in
        flex.addItem(imageStar1).width(widthStar).marginLeft(1)
        flex.addItem(imageStar2).width(widthStar).marginLeft(1)
        flex.addItem(imageStar3).width(widthStar).marginLeft(1)
        flex.addItem(imageStar4).width(widthStar).marginLeft(1)
        flex.addItem(imageStar5).width(widthStar).marginLeft(1)
             flex.addItem(fonLineView).height(heightLine).grow(1).marginHorizontal(8).alignSelf(.center).define({ (flex) in
            flex.addItem(lineView).grow(1)
        })
        flex.addItem(countMark).width(25)
    })


}

But then I want to install lineView.width = 100
lineView.flex.width(100) this does not work

lineView.frame.size.width = 100 it works

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

Setting directly lineView.frame.size.width will work until the flex container will be relayouted by contentView.flex.layout(). After lineView.flex.width(100) (you may have to call lineView.flex.markAsDirty() too, I'm not sure) you must relayout the flex container using contentView.flex.layout().

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

@lucdion Thank you so much. It works.
lineView.flex.width(width)
contentView.flex.layout()

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

There is one more problem. FlexLayout incorrectly determines the size of the button.
And if there is a lot of text in the button, it does not change in size.

lazy var button: UIButton = {
let button = UIButton(type: .system)
button.contentHorizontalAlignment = .left
button.sizeThatFits(.zero)
button.titleLabel?.textColor = UIColor.black
button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
button.titleLabel?.lineBreakMode = .byTruncatingTail
button.titleLabel?.numberOfLines = 0
return button
}()

let label: UILabel = {
let label = UILabel()
label.numberOfLines = 0
label.font = UIFont.systemFont(ofSize: 14)
return label
}()

simulator screen shot - iphone 8 - 2017-11-07 at 10 09 19
simulator screen shot - iphone 8 - 2017-11-07 at 10 09 33

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

I cannot fix the error

Module compiled with Swift 4.0 cannot be imported in Swift 4.0.2: /Users/slm/Documents/Project/Flip/Carthage/Build/iOS/FlexLayout.framework/Modules/FlexLayout.swiftmodule/x86_64.swiftmodule

*** Building scheme "FlexLayout" in FlexLayout.xcodeproj Build Failed
Task failed with exit code 65:
/usr/bin/xcrun xcodebuild -project /Users/slm/Documents/Project/Flip/Carthage/Checkouts/FlexLayout/FlexLayout.xcodeproj -scheme FlexLayout -configuration Release -derivedDataPath /Users/slm/Library/Caches/org.carthage.CarthageKit/DerivedData/9.1_9B55/FlexLayout/1.1.5 -sdk iphoneos ONLY_ACTIVE_ARCH=NO BITCODE_GENERATION_MODE=bitcode CODE_SIGNING_REQUIRED=NO CODE_SIGN_IDENTITY= CARTHAGE=YES archive -archivePath ./ SKIP_INSTALL=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=NO CLANG_ENABLE_CODE_COVERAGE=NO (launched in /Users/slm/Documents/Project/Flip/Carthage/Checkouts/FlexLayout)

This usually indicates that project itself failed to compile. Please check the xcodebuild log for more details: /var/folders/0_/r8ll6bnx44g68llzb22frp_c0000gn/T/carthage-xcodebuild.53dsTj.log

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

@sLm-s I have fixed the carthage compilation, sorry for that. I'll check your other problem.

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

@sLm-s for your button issue. It looks like the UIButton sizeThatFits always returns an height matching one text line. If you call this line in layoutSubviews

let size = button.sizeThatFits(CGSize(width: frame.width, height: .greatestFiniteMagnitude))

The size.height is always the same value, even if the text is longer.

It looks like if you want to have a button with a multiline label, you'll have to subclass UIButton and implement the sizeThatFit method.

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

@lucdion Thank you for your help and your work.

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

Hi @lucdion. Whether it is possible to make the fixed size of the container, and the FlexLayout calculated the size of all objects this container ?

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

Other question: whether it is possible to make the container transparent and in it objects not transparent. Or create transparent background for a container

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

The container can be transparent by setting its background to UIColor.clear.
I'm not sure to understand your question related to "fixed size of the container", can you rephrase it?

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

Here is an approximate problem.

simulator screen shot - iphone 8 - 2017-11-10 at 09 29 52
simulator screen shot - iphone 8 - 2017-11-10 at 09 39 51

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

Hi @lucdion . Is it possible to determine the coordinates of the object inside the container FlexLayout ?

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

If you keep a reference on your object (view), you can always retrieve its frame property after the container has been layouted (ex: myView.frame.origin.x, myView.frame.origin.y)

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

For tips for UICollectionView, you can check how this has been achieved in the UICollectionView sample.

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

How to be if you need a specific size and not objects inside the cell. For example, the height is 320 and the height of all objects is 280 then I need these objects to stretch to the entire height of the cell 320 more precisely those that can for example UILabel

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

Created shoot there are several kinds of collections placed in it. If the turning screen fires the Villtransition method. But the problem is when you return to the previous screen the layout changes its dimensions in your eyes and it doesn't look very nice.

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)

    coordinator.animate(alongsideTransition: { (context) in
        self.layout()
    }) { (completed) in

    }
 
}

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

@sLm-s to stretch items you must specify the grow value for at least one of the container's children. For example, if you specify a grow value for all container's children, the available space will be equally distributed. By default the grow value is 0, which don't expand.

Sometimes you also need to specify the shrink value if the container is smaller than its children size.

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

@lucdion Unfortunately this does not help. Here are the screenshots.
I open the application the first screen appears, I rotate the in landscape. And I turn to a new screen, then I turn over to the portrait view and go back. After this, the calculation of the layout is not correct. But the second passes and the layout takes a normal form.
And the most incomprehensible moment for the first time works normally

simulator screen shot - ipad pro 9 7-inch - 2017-11-15 at 08 51 52
simulator screen shot - ipad pro 9 7-inch - 2017-11-15 at 09 10 17
simulator screen shot - ipad pro 9 7-inch - 2017-11-15 at 08 54 41

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

Your FlexLayout helps me very cool. One problem a lot of questions)). I'm not an experienced yet developer((.

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

Hi @sLm-s, could you share me your whole project, or at least extract those screens that have issues. I could look at it.

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

I do not even know how to show you the part of the project so you can understand it and. I filled in the code in which I create a layout with the help of UIScrollView. There are several types of UICollectionView in it. When I click on a cell, I switch to the same controller but with a different layout. And when I start to rotate the screen the layout is well updated but if I go back to the previous controller then the layout is not updated normally. Sorry for my bad English

UIscrollView I use because it has a smooth scrolling

ScrollCatalog.zip

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

@sLm-s if you completely comment the code in viewWillTransition in ScrollCatalog, and simply depend on the viewDidLayoutSubviews method, does it work correctly?

Also to clean up a little bit your layouting code, you should probably move all your layout code from viewDidLayoutSubviews into your layout method. This way all layout related code would be at a single place.

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

In viewWillTransition uses only layout() the rest is not important

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransition(to: size, with: coordinator)

    coordinator.animate(alongsideTransition: { [weak self] (context) in
        
        guard let strongSelf = self else { return }
        
        
        strongSelf.layout()
        
    }) { (completed) in

    }


}

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

In viewDidLayoutSubviews looks like this. the rest are additional chips

override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()

    scrollView.frame = view.frame
    rootFlexContainer.frame.size.width = view.frame.width
    
    rootFlexContainer.flex.layout(mode: .adjustHeight)
    
    scrollView.contentSize = rootFlexContainer.frame.size
    
   
        }
    }
    
}

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

In file parsScrollCatalog.swift created the whole layout

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)
Does not work for layout recalculation?

from flexlayout.

sLm-s avatar sLm-s commented on May 11, 2024

Hi @lucdion . Thank you for your help. I figured out why the layout was not working correctly. I apologize for the stupid questions. I'm just learning, very little experience.

from flexlayout.

lucdion avatar lucdion commented on May 11, 2024

No problem, happy to try to help you!

from flexlayout.

Related Issues (20)

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.