UIScrollView Quick Taps Not Being Fired *Bug* - iphone

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.

Related

How can achieve an iPhone home screen like reorganization feature?

I have a vertical UIScrollView just wide enough for a single column of buttons. The buttons can be dragged by the user, but when one is being moved I want the other buttons to move up or down out of the way. The only way that I can think of to do this is in the UIPanGestureRecognizer responsible for moving the button, every time its method gets called running a for loop in the subviews, checking the y values. That seems incredibly inefficient, and would require keeping track of which buttons have already moved to prevent moving them more than once. There has to be a better way. Any ideas?
the same functionality has been implemented in this project and in this project also . I hope project code will help you to solve your problem.
Your could use a UITableView with a custom UITableViewCell. Just implement canMoveRowAtIndexPath, moveRowAtIndexPath and targetIndexPathForMoveFromRowAtIndexPath on UITableViewDelegate

Any ideas on how to make a UIPickerView from scratch?

I've decided that I don't want to ever use UIPickerView again... it's completely inflexible in terms of functionality, design, and size (height). It also occasionally gets stuck between rows, and the delay that occurs between letting go of a wheel and when the delegate method is fired indicating that a new row has been selected (because of the "settling in" animation) has caused lots of problems in the context of the apps I've been working on.
That being said, the user-friendly aspects of UIPickerView are good, and I'd like to try to replicate it. I've tried to research different ways that this might be done, but without much success. Does anyone have any ideas as to what would be involved to make something similar from scratch?
I was trying to get a UITableView subclass to behave in such a way that whatever cell was currently in the middle of the table (it would change while dragging, etc.) would change its background colour to something different implying that it was "selected". As soon as the table was dragged such that the "selected" cell was no longer in the middle, the cell would go back to normal and the new middle cell would change colour. So this would be like UIPickerView in a sense that you don't have to tap on a cell; instead you just drag to have one selected by default.
I figured it should have been easy enough to intercept the "touchesMoved" method of UITableView and add some code that looped through all currently viewable cells in the table, checking to see if their frames overlapped the center point of the table, and changing their appearance accordingly (plus sending a notification to other classes as needed to indicate the "selection" change). Unfortunately, I can't get this to work, as the "touchesMoved" method doesn't get called when I drag the table. Am I missing something obvious?
Any ideas or suggestions would be very much appreciated at this point... I made an app that relied heavily on UIPickerView objects, and because of the problems I've run into with them, I'll have to abandon it unless I can figure out a way to make this work.
Thanks very much,
Chris
Remember that a UITableView is a subclass of a UIScrollView, and the UITableViewDelegate gets all the UIScrollViewDelegate method calls too. scrollViewDidScroll: sounds like it would easily fit the bill for knowing when the table view was scrolled.
As for finding which row is in the middle of the view, just use indexPathForRowAtPoint:.

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.

Using a UIButton as an Accessory View for a UITableCell

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!

Mysterious UITableView stuck problem

I'm new to iPhone development. I'm working on a table view (default UITableView subclass) that contains complicated custom cells, with multiple subviews and controls. Scrolling is not very smooth, but I'll just leave that for now.
The question is, when I'm scrolling the table view with quick swipes, the table sometimes suddenly stops scrolling and the scroll indicator will not disappear, and I have to swipe again to make it scroll.
If the table contains very few rows, say, 5 or 6, it never stuck. The custom cell class I used is from the example provided here: http://blog.atebits.com/2008/12/fast-scrolling-in-tweetie-with-uitableview/
Can anyone give a hint or solution to this problem? Thanks in advance.
Table cells are only created when needed, that is when they come into view and they are usually unloaded and released when they go out of view.
Put in an NSLog( #"Cell loading" ); in your cell creation code and check the console to see this happen as you scroll.
Are you using caching? The docs demonstrate how you can cache table cells to improve performance. What else are you doing when you're creating table cells? If there's any performance slow downs you should probably not have that happen while creating cells.
What I do is I generate all my content before the table loads and when cells are created all that content is simply placed into the view.
Any kind of drawing will drastically reduce performance especially if you're using transparency.
For posterity, and only valid if you are using Unity-iphone: this problem was driving me insane and I fixed it with the suggestion in this post:
http://forum.unity3d.com/threads/113815-quot-Sticky-quot-scrolling-in-UITableView-and-UIScrollView-when-interfacing-Unity-and-Obj-C
Changing the preprocessor flag to
#define USE_DISPLAY_LINK_IF_AVAILABLE 0
gave the issue a happy ending.
I'd take a look at your cellForRowAtIndexPath method - for a couple of possible problems.
If you aren't using the cell reuse that will slow things down a lot and if you are re-allocating or re-initializing your custom cells in the cellForRowAtIndexPath delegate method that can cause big performance issues.
If you post your code for that method we can give you some hints as to what might be causing it.