How to make adapter with different number of views in each of item in list view - adapter

I want to make a list view with different number of views in each item.Like this
ListView
listitem1:
TextView1
TextView2
TextView3
listitem2:
TextView1
Button
listitem3:
TextView1
TextView2
I have tried to use the baseadapter and addview on the getView method but it doesnot work and it create more views than I want. I dunno whether there is a way to do it on using the adapter. I cannot find any solution in stackflow and I want someone can give me an simple example for me. Thank you.

Related

TextFields don't respond when I click on them! It's like they're glued or something?

Yo!
I have created a design in the Main.storyboard.
I have a lot of views that I'm using to slideIn/slideOut etc.
The problem is that one of those views have some textfields. None of them responds on click. If I want to interact with them, I have to call 'becomesFirstResponder', but still, the other textfields are not able to respond on click.
I've tried a lot with "bringSubViewToFront" etc, but nothing seems to work. I don't know how to make those TextFields able to interact with.
They're all set delegate, enabled, and all of that.
tv1.delegate=self
tv2.delegate=self
tv3.delegate=self
tv4.delegate=self
What else can I try?
RIGHT, FINALLY!
I do NOT recommend this shitty solution.
But, if you suffer a problem similar to mine, just get it to work with this solution:
Add button for ALL of your textFields. Place them where your UITextFields are located and make the Buttons transparent in Attribute-inspector.
Add Action to the buttons in your ViewController-class and name them something "textField1_isEditing".
Inside the code-brackets, place following: yourTextFieldsName.becomesFirstResonder()
DONE! Now you can use a TextField that don't respond on buttonClicks, even if you have 100% sure set "userInteractionEnabled" "enabled" etc..

How do I show and/or hide a subview using swift

So I've created a ViewControl in my storyboard that has 3 subviews. Each one represents a different view I want to show depending on which table row was selected on the previous screen (NavControl). I start with all of the subviews hidden via the Attributes Inspector's 'hidden' attribute being checked. All of the objects within each of these views are NOT hidden, but are being hidden because the subview itself is hidden (obviously). Thinking I could use the tag attribute I've given each of the three subviews a tag (0, 1 and 2), but can't figure out how to use that either (just in case this is useful as providing me with an option of how to do this I wanted to mention it here).
So, how the heck do I show and then hide any of these subviews? I don't want to go through each object in a subview and toggle its hidden property to true/false I feel like I should just be able to 'show/hide' the entire subview. thus achieving the same result, but much more succinctly.
I can't find anything that will help me via web searches or stackoverflow searches.
My code is very simple. I capture the row that was selected in the previous screen and pass it to a variable on the details screen that contains the subviews. I know this is working because I've set up println()'s on the details screens viewDidLoad function. So now all I have to do is going into each of these conditions and tell it which subview to show and/or hide.
Thanks I appreciate all of this communities help! I'd be lost without it.
Use this to hide a view in swift
viewVar.isHidden = true
You should create IBOutlets for each of the three subviews. Then you can show/hide each of them directly from those references. If you hide a view, it will automatically hide its subviews.
Once you have an outlet for the view, you can do this:
viewYouWantToHide.isHidden = true
If you have tags for each view you can hide and display them using:
Objective C
For Hiding:
[[self.view viewWithTag:1] setHidden:YES];
Showing:
[[self.view viewWithTag:1] setHidden:NO];
In Swift:
Hiding:
self.view.viewWithTag(1)?.isHidden = true
Showing:
self.view.viewWithTag(1)?.isHidden = false
NOTE: Replace 1 with your tag value.
however the fact that isHidden is a naming convention for checking the status and is a getter method
but despite that fact in swift we use it as setter and getter property
view.isHidden = true

Is it possible to 'hyperlink' text within a UILabel/TextView but activate a segue on tap of this 'hyperlink'?

I say 'hyperlink' because I don't know what else to call it, and that is how i'd like it to appear.
Obviously this is possible using a combination of labels and buttons, but my labels and buttons are programmatically generated and I imagine i'd have to also programmatically arrange them, which would likely be tedious and inflexible in terms of changing font sizes etc.
Any ideas/approaches would be much appreciated!
As an example, look at Instagram's following and news feed:
You should set userInteractionEnabled and then add a UITapGestureRecognizer to the label.
Have a look at Nimbus Attributed Label it can provide the functionality you are looking for.

How can I create a dynamic overlay for a UIButton?

My application has a few portions that have really big buttons (640x130, 230x150, etc.) What I need is to have a way to update different portions of the button, with different text. Initially, I assumed that in my code I could create various UILabels and then add them as subviews to my button. However, as soon as I try to add a UILabel to the button as a sub-view, my app crashes.
What is the easiest way to create an overlay for a button, that I can completely layout myself, without preventing button taps from being interested using overlay controls?
I imagine there are multiple ways to solve this problem. However, the best solution for my case should use the fewest lines of code (I have quite a few of these types of buttons) and I'd like to be able to continue using some form of configurable button within IB.
I'm not opposed to subclassing UIButton but, if I do, I would like to be able to use it in IB. I've never created a custom UIView for such a circumstance, so I'd need help defining that type of subclass so that it will work correctly in IB.
You need to add the subview to the containing view - not the button. To ensure that is doesn't interfere with button presses, be sure to set it to:
[myCustomTextOverlay setUserInteractionEnabled:NO];

Make green color UIActionSheet button?

I know I can access a individual button on a actionSheet using a for loop to access the particular button in the action sheet I want, but the thing is, how would I make a green button?
I know each button acts almost identically to a UIButton so how should I go upon making one of my buttons in the action sheet green?
I just need some tips or help with this as it is the last part of my app that isn't done!
Thanks!
When I have needed customizations for UIActionSheets, sometimes I find methods to make it happen simply, but more often I end up having to set up a custom view on way or another. I've added all manners of custom controls with:
[sheet addSubview: myCustomActionSheetController.view];
You might need to set the size as well.

Resources