last day (15 days later) » 

9:05 AM
-1
A: Dynamic height for custom collection view cell by using autolayouts

Rock Balbaouse this method and calculate the size that is appropriate for you and return it. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let Labell : UILabel = UILabel() Labell.text = ...

 
please tell me how to calculate the size's @Rock Balbao
 
I am creating a temporary label which takes the text as label.text and calculates its height thus in this way I will get the size of the label that will be used at real time. and I can set the height of collection view and as label's height + some space you want to keep in between the cells. @RahulPatel
@RamcharanReddy Tell me what can be there in your UIView? and textview. use intrinsic height of those 3(button,view,textview) add with label's height and then return it
 
the UIView can be added with any number of subviews like custom radio buttons, checkboxes and etc. button has fixed height. TextView also has fixed height but it will toggle. @RockBalbao
before going in to cellForItemAt() method , sizeForItemAt() will get execute which means before assigning any data, we can not give the size
 
Where are you getting your data from? let me give you full working code
 
data from Webservices. As soon as I get the complete data from web services, then collection view will start loading. Yea. Please provide the full working code. @RockBalbao
Hi @Rock Balbao
 
 
2 hours later…
11:28 AM
Hi
@RamcharanReddy tell me what do you get from webservice
or provide me a code than I can give you working code. Other wise the solution is creating a custom class for collection view
and that is difficult. But is possible way
 
11:56 AM
the code that i put is the only code
I have the custom cell class in which it has outlets for all of the subviews
{
"Status": 200,
"Data": [
{
"SectionName": "Basic Details",
"QuestionTitle": "Were any other policy violations observed? If YES, please explain:",
"QuestionId": 26,
"AnswerMode": "RadioButton",
"AnswerValue": "Yes,No",
"IsMandatory": "True",
"IsCommentRequired": "True",
"IsRemarkBased": "False"
},
{
"SectionName": "Basic Details",
"QuestionTitle": "For any violations, what was the corrective action that was taken?Please explain:",
"QuestionId": 27,
"AnswerMode": "RadioButton",
"AnswerValue": "Yes,No",
this is the json that i get from the webservice
based on the answer mode ,I need to put the subviews inside the view
u got it ?
 
okay.. so you need to put 4 radio buttons? correct with 4 labels asking for yes or no?
 
yea yea
exactly
If answer mode is check box...I need to put checkbox there
there are only yes or no values right
so only 2 radiobuttons i need to add them to uiview
now u got some clearity. isn't it?
will you help me @RockBalbao
 
12:17 PM
yeah sure..
okay so can you show me the code you use to make that view
?
 
I used storyboard to create the view and tried to add constraints
 
Send me the method of cellForItemAt method
no not the collection view
the view that you're creating dynamically according to the buttons
or radio buttons or checkboxes
 
for value in values{
radio1 = SSRadioButton()
radio1?.circleColor = UIColor.black
radio1?.circleRadius = 7.5
radio1?.isUserInteractionEnabled = true
radio1?.setTitle(value, for: .normal)
radio1?.setTitleColor(UIColor.black, for: .normal)
radio1?.titleLabel?.font = QUESTIONNAIRE_QUESTION
let width = NSLayoutConstraint(item: radio1!, attribute: .width, relatedBy: .equal, toItem: nil, attribute: .notAnAttribute, multiplier: 1, constant: 100)
contentView.addSubview(radio1!)

let topConstraint:NSLayoutConstraint?
values has [yes,no]
SSRadioButton is the custom uibutton for radio button
got it?
 
12:34 PM
okay
please wait
 
sure sure
Where u r belongs?
 
I am from India
 
Me to.which state?
 
Gujarat
 
I'm from Telangana
Where do you work ?
 
12:37 PM
I am a trainee
Just learning things from where I can
Right now I am an intern at Infostretch Corp. Pvt. Ltd
 
Ohh great
How much do they pay to you
 
Nothing
I am just an intern
 
after internship
 
No idea. According to my performance. minimum 3 LPA
 
that's good
 
12:41 PM
You're system engineer at Infosys?
 
yea
how do u know
 
Your profile. :)
 
:p
anything working?
 
how much do they pay?
 
from this month 4 LPA
 
12:45 PM
yes I am calculating radio button height. dynamically and according to that you can get height of your view so according to that you'll get height of whole cell. If this doesn't work. I learned to create custom class. You have to do that
Good :)
 
ok ok. try
 
are you using this git to create radio button?
 
yea
same one
 
okay so radius is custom.. Correct?
and you're giving it fix
7.5 correct?
 
yeaa
7.5 is radius
 
12:56 PM
now one more question. json will give you same type of buttons all time or different?
means all 4 radio buttons or all 4 checkbox?
will the scenario will be same?
 
only
any number of values can be there
 
okay not compulsory 4 but n times will be there but button category will be same?
 
yea
when it comes to check box
it's height will be different again
one more thing. that textView will get toggle on click of that button
 
have you tried table view?
 
No...directly used it
re-sizing table view cell or collection view cell. both are similar only
 
1:04 PM
then this scenario will be more easy in table view
 
Even if it is possible please tell me to do
if you can provide a working copy of this
 
I will create a demo and will send you
 
it will be a lot pleasure
thanks dude
 
sure
 
tell me your name and mobile number, if u dont think that i'm fraud :)
 
1:08 PM
I will not create a view inside that because creating a view may disturb it.. we will create the buttons directly and will give constraints to them. If we give correct constraints. the tableView.rowHeight = UITableViewAutomaticDimension will do the rest.
 
beauty
nice idea
u also try it
tell me your name and mobile number, i will create a watsapp group for iOS developers
so that we can help each other and refer one other in their companies
 
My name is Jay. 7405036867
right now don't add me in a group
I will inform you later If i want to join for sure
 
ok.
Atleast, I will have your contact. is that fine
 
yeah sure
 
1:26 PM
is it working
 
1:42 PM
right now urgent task came.. from office. I will be available tomorrow morning. Will it be okay if I make the demo tomorrow? because I will be free till tomorrow noon. I have created some of it. its working but its static. I will create a dynamic version tomorrow and will give you the demo
 
ok. can u send me the static one now
 
sure.. your email id?
 
bablu.dot@gmail.com
sent?
 
2:02 PM
doing that only
Please message me in whatsapp now. i am leaving office
 

  last day (15 days later) »