OHAttributedLabel and UITableView - iphone

I am using OHAttributedLabel to create a text link inside my UITableViewCell. However, when I am tapping this link, I am having hard time getting the tap through, it seems like I have to hold my finger a lot longer to get OHAttributedLabel to realize that I want to tap the link.
I do not have this problem outside UITableViews, everything works perfectly. Curiously, this same error happens also in tableViewFooter and header. I have set userInteractionEnabled = YES for the label, and NO for the cell. What could I be doing wrong here?

Related

Label of UIButton appears intermittently inside a UITableView

I have a UITableView with some data. One of controls is a UIButton, with a label assigned. So, in rare cases, when I push the UITableView screen, the buttons appears without label. After I scroll the UITableView or rotate the device, the label appears.
I put a NSLog entry inside the drawRect method. And It's not called in some cases.
Some advices?
Thanks
i found same problems that some methods rarely not called. make sure delegate is properly set and then check the result
After analyzing my code I saw some characteristic that caused the problem. The process of construction of my screen was occurring in a different thread of the events thread. So, I fixed this and everything is fine now.
Thanks.

custom uitablviewcell does not call didSelectRowAtIndexPath in the controller

I have a custom UITableViewCell completely written in code (no IB), it has an accessory button that simply calls didSelectRowAtIndexPath on the table view, and it works correctly and the method is called without problems.
However, when I tap on the cell itself (not on the accessory view) nothing being called, why ?
EDIT: the code is huge to put here ... however, the custom cell contains a ton of labels, couple images and scroll view ...
This is a shot in the dark, but if each cell has many different objects on it (i.e. images, labels, etc) then it may not be working because those objects are what the user is hitting when they try to click a cell. Does the cell turn blue (indicate selection) at all? If not, try hiding/removing those objects for now and see if it works.
If that is the case, then what you may want to do is create an invisible cell or button that sits on top of the other objects and calls didSelectRowAtIndexPath from behind the scenes.
This should solve your problem:
Raise selection event (didSelectRowAtIndexPath) when subview of UITableViewCell is tapped
Try setting your view's userInteractionEnabled property to NO.
This will make it ignore all touch events, and then the views under it will be able to catch these events. - Felipe Sabino
I'd partially answer my question: the wide scroll view is preventing the cell from calling didSelectRowAtIndexPath, removing the scrollView will solve the problem, however, I want to call this method with the existence of the scrollView ... anyone got ideas would be highly appreciated ...
You must post your code to understand what have you done...You have to check out this example to understand whether your code is correct or not...
http://www.edumobile.org/iphone/iphone-programming-tutorials/impliment-a-custom-accessory-view-for-your-uitableview-in-iphone/

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];

How do you make a UITextView that supports URL links and can be edited?

I have a UITextView that is properly displaying URLs thusly:
contentView.editable = NO;
contentView.dataDetectorTypes = UIDataDetectorTypeAll;
My goal is to make it so you can still tap on this text view in order to edit its text at a particular location (just like the built-in Notes app). That way, if you tap a link, it'll launch a browser, but if you tap anywhere else, it'll start editing at the point where you tapped. Should be easy, right?
Not so far. Subclassing the UITextView and overriding touchesEnded gives you a chance to set editable to YES. But when you do that, the text view doesn't remember where you tapped (the selectedRange doesn't get set properly), so editing always begins at the bottom of the text view.
I've even tried using the undocumented setSelectionWithPoint method, but it doesn't behave as you'd expect.
Can anyone think of some way to achieve a proper tap-to-edit UITextView with tappable links?
Perhaps you could try either retaining the UITouch and UIEvent or forging copies using custom classes that have the same class signatures, then re-send the touchesBegan: and touchesEnded: events after setting editable to YES.

UIPageControl render quirk with UIScrollView

I'm building an iPhone application and like most I am trying to implement a UIScrollView with a UIPageControl, however I am coming across a very quirky behavior, which I assume may be a bug. Hopefully one of you has seen this before because it is driving me nuts.
Basically, the page control works fine, everything is hooked up and works normally on all accounts EXCEPT, with certain placements of the UIPageControl within the UIView, the UIPageControl will cease to render.
I'll just take screenshots of the XIB window to help illustrate... here's a placement that works perfectly fine:
http://www.jasconi.us/prob1.png
The UIPageControl is placed physically above the UIScrollView. Works great, everything is visible and working.
The next two DO NOT work:
http://www.jasconi.us/prob2.png
http://www.jasconi.us/prob3.png
The first one is simply placed below the scroll view. Doesn't render at all.
The second one is placed above the scroll view without technically being inside of it. Also doesn't render.
What the hell is up with this? I've tried using
[[self view] bringSubviewToFront:pageControl];
...to no avail.
Any ideas?
OK I found the answer to this, it's a little six degrees of Kevin Bacon.
This isn't actually a software bug, but a XIB quirk, for some reason the lower placement of the page control in combination with the default settings for autosize and anchor seem to jettison the control into outer space.
If you turn off all auto-scaling and auto-sizing and auto-anchoring and all that other crap, the controls appear exactly as you expected. The fact that it appears reliably when placed above the ScrollView is an oddity.
shrug.
Hope this helps future iPhone initiates.
Did you check to make sure that numberOfPages is not 0?
If you set a breakpoint can you see that pageControl is not nil?
I was still encountering this exact same problem, even after trying everyone's posted answers. My issue ended up being a little more "DOH":
I was using UIPageControl at the bottom of a modal FormSheet, however, I forgot to set the size of the view as Form Sheet in the xib. This caused my page control to be off the screen and never visible.
Moral: set view size (Full, Form, Page, etc) in your xib on the base view.
This will sound like a real no brainer, but I got caught out by it.
By default, UIPageControl expects to be on a dark background. IE: The dots are light gray, and white for the current page.
I used UIPageControl on it's own with no scrollview to change the time range of a graph I was rendering with drawRect:
Long story short, the graph background was white, so the page controller worked, I just couldn't see it. The solution was putting the graph itself in a subview, and making the parent that contained the page control have a dark background.