Using a UIButton as an Accessory View for a UITableCell - iphone

I have run into an interesting bug where it appears that when you select a UITableCell it changes all of it's subviews to their highlighed state. This includes my accessoryView which is a UIButton which obviously I only want highlighted when the user presses like a normal button.
I have a friend who went as far subclassing UIButton to override this in his app and manually managed the state for this type of behavior but that seems drastic to get what should be the expected behavior. So, I am wondering what other solutions people have come up with for this problem.
Has anyone else had this issue? If so, what did you do to work around it? Any code samples as well as ideas are very welcome!

I ended going with a custom button on this like Jesse Recommended abd set both the highlighed and normal state to the same image. It seemed to work well enough for what I was trying to do. Thanks again!

Related

UIScrollView Quick Taps Not Being Fired *Bug*

I'm seeing an issue with UITableViews and UIScrollViews. For a UITableViewCell to be selected you have to give it a fairly long tap for it to register. A quick tap on the screen won't do the job. Setting delayContentTouches to NO isn't the answer either because it highlighted cells "too fast" as compared to how it should work properly.
Anyone know the problem?
I was using some weird 3rd-party code that was adding categories to UITouch.... figures.

IPhone UIButton doesn't respond in a UIScrollView

I'm an iPhone dev newbie, and I'm having a problem slightly similar to a few posts I read around here, but none of them seemed to help.
I have created a UIScrollView, with a UIView as its content (a subview). During runtime, the UIView is populated with labels and buttons. Everything looks fine, scrolling works perfectly, but the UIButtons never fire when pressed, no matter what I do. I've tried many combinations of properties suggested here, to the best of my understanding, but still nothing worked. I'm afraid I might have misunderstood something about the mechanism.
I should mention that everything is done in code (no IB).
Any suggestions?
My bug (written in the comments of my question) was not setting the frame of the contentview that was the parent of all buttons. The result was strange - I could see the button subviews (which was why it took me a while to find the bug) but could not click on them. oops!
This also may happen, when your custom UIView userInteractionEnabled is NO (default is NO).
try [btn becomeFirstResponder];

iOS UIButton in UITableView Header

I have a subview that acts as a container view in a table header. In that, I have a UIButton. The button is not receiving any touch events. (Yes everything is wired up properly in IB...)
So my question is, is it a common problem to have buttons not receiving any events in the header? Do I need to forward any events?
I can't really post any code, since it would appear to be more of an IB problem. Anyone experience this before?
UPDATE: If I put the button in the footer, with no container view, it will work. So perhaps it's because it is in a view inside the header??
Wow, I feel like a moron. I didn't have user interaction enabled. Sorry for wasting all your time guys...
I've included UIButtons and even UITableViews in my table header before, so I don't think it should be an issue. Something is just not setup correctly. I didn't have to do anything special to get touch events to fire.

iPhone application - pop up dialogue - sort of

I have an iPhone application which is, in essence, a list. There is a UINavigationBar at the top, and then there is a UITableView which holds the list. I'd like to have an option in some way or another of allowing the user to sort the list in different ways. So, in my mind, I picture having a NavigationItem on the UINavigationBar that, when touched, a little pop up dialogue comes up. You select the "sort" you want, a check mark appears next to it, and the dialogue goes away.
I'm not really sure how to do this. I tried creating a UIView, adding a UIViewController onto it (which held this list of different "sort" parameters (ex. sort alphabetically, sort by date, etc) in a UITableView. But the UITableView isn't responding to any touches, and I'm not sure why.
Does anyone have an idea for using Apples wonderful interface for having an option like this? I can't use a UISegmentedControl below the UINavigationBar, because there are 5 possible options, and I can't fit all that in a single UISegmentedControl.
This sounds like a job for the UIPickerView. You could just slide one up from the bottom of the view whenever that button is pressed. I've done this in the past and it works well.
You won't get a checkmark, but if you want a pop-up I suggest using a UIAlertView.
Have you looked into UIActionSheet at all? https://developer.apple.com/documentation/uikit/uiactionsheet
It seems like it might be a good fit for this approach. The action sheet will be a bit tall since you will have 5-6 buttons in it, but it should get the job done and they are really easy to implement.
The way you are approaching it with displaying another view with its own UITableView in it would work also, but it doesn't seem like the best approach to me. Granted, if you are set on going with that approach, provide us with some code so we can try to figure out why the UITableView isn't responding to touches.

UIButton as a subview in UILabel

I am trying to dynamically add a UIbutton as a subview to UIlable. But I am not able to click the button. It seems that the label doesn't allow the buttonTapped event to occur.
Can somebody explain what exactly is happening here? and can anybody give me an alternative for this? thanks!
funny, I got answer on my own after 5 mins of posting this question. It seems that I had to enable my userInteraction on the labels.
i.e. -
lbl.userInteractionEnabled=YES;
Your question (and subsequent answer) don't speak to the wisdom (or lack thereof) of doing what you're attempting. UILabel objects aren't generally meant to be interactive, and placing a UIButton as a subview to the label, just because you can do it, doesn't sound at all like it's following the Apple HIG for iPhone.