I am trying to do a pull-to-refresh action on a collapsable tableview that is a subview of a UIView.
I have searched StackOverflow and found an answer, but it still doesn't work.
Have anyone faced this problem before? I've attached a picture of the code I did, hoping someone will help me out with it.
Which UIControlEvent you have used against forControlEvents ?
I've found the problem, I accidentally set the bounces to NO instead of YES, thats why it is not able to pull downward
Related
When showing the detail viewcontroller for the first time, the inputAccessoryView will render the text immediately, but when you go back and try it again, the text doesn't get rendered untill the animation completes.
See demo project here:
https://github.com/SabatinoMasala/accessoryview-demo/
If anyone has a resolution, explanation or workaround, I'd be glad to hear it!
I've been experiencing the same issue and I found a simpler workaround. It seems that this bug is related to the fact that inputAccessoryView animation is using a snapshot of the view. Forcing the snapshot appears to resolve the issue:
let _ = accessoryView.snapshotViewAfterScreenUpdates(true)
I tried messing with your project and, unfortunately, I saw the same behavior that you did. This may be a bug in UIKit.
I found a workaround for this issue, take a look at the HackFix branch of the project here: https://github.com/SabatinoMasala/accessoryview-demo/tree/HackFix
We achieve this workaround by adding a dummy textfield to the view hierarchy, which we then remove on ViewDidAppear. On ViewDidAppear we also show the InputAccessoryView, which was hidden beforehand.
So I have added a UIUITableView to a UIViewController. I can't use a UITableViewController for reasons I don't need to explain since it will be unnecessary information. Anyway, I have set the delegate, and the data source to this viewController. I've added the delegate and datasource protocols as well. The cells are populated correctly, so the datasource is working fine. I can also scroll so it all works fine.
However, I can't get the didSelectRowAtIndexPath to trigger. It SHOULD trigger, but doesn't. I've read and a lot of issues with this can be correlated to a UIGestureRecognizer, but I haven't implemented one. I also use the standard UITableView, so not a custom made one.
If I long press the cells (3-4 sec) then it gets triggered as it's supposed to. This suggests that there is some issue with another view or something absorbing the tap gesture, which I have no control over. How would I solve this?
No, it's not didDeselectRowAtIndexPath.
Yes all delegates and datasources are correct, since I can get the delegates/sources to trigger.
Yes, Single Selection is set on the TableView in the inspector.
Yes, everything has user interaction enabled.
If I just copy the code over to a UITableViewController it will work just fine, but right now that is not an option, I'm afraid. Anyone got any ideas on how to solve this? Most people who've had this issue has either had the issues in the list above, or added a UIGesture on top of the UITableView - I haven't.
I want to start by saying that I appreciate all the answers here provided, it gave me a lot of things to try out so I learned a lot - thanks! None of your suggestions worked, but simply because I'm a complete idiot. I said in the post that I did NOT implement a UIGestureRecognizerwhich I didn't...in that class, but in its super class. So I DID in fact implement it, but in a class that this ViewController was a subclass off. The only reason I didn't remember it was because I haven't looked at that super class for weeks.
Someone did suggest it in the comments that I should check for it, and I did and I was already certain I didn't implement one, so I quickly dismissed it. But now, after about 4 hours of debugging and recreating the project, adding things one by one, I eventually realized that the only thing that differed at this point was the Super Class, and the first piece of code I see when I open the file up was a GestureRecognizer...
So keep this in mind in the future everyone - I know I will. Thanks again for the help!
Sincerely,
The complete idiot.
Make sure you don't add any controller in that cell, which covers the entire cell and also the user interaction of that controller is enabled.
Due to that controller's user interaction enabled the tap action is taken by that controller and when you long press that cell, that cell will receive your tap.
Example :
UIView *_view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _cellWidth, _cellHeight)];
[_view setUserInteractionEnabled:YES];
[cell.contentView addSubview:_view];
In the above case that view got your tap instated of the cell.
I have a custom UIView and I have many views in my hierarchy. Whatever I do, my custom view is always in front of all the others when I run on iOS 7. There is no problem in iOS 8 though. In IB, the view is far behind my other views. Is there any way to override this behavior? I've tried incrementing one of the views' layer's zPosition but it didn't change anything. Why can this happen?
I've ended up using bringSubviewToFront: method of UIView and it worked. I still have no idea why it was displaying at the wrong order though. I'm accepting my answer as it solved my problem, but any recommendations on why it happened is welcome.
Hey guys I added a UIImageView to the subview and want to remove it after a couple of seconds.
self.view.addSubview(car)
Now I want to remove the image completely. I tried something like:
self.view.delete(car)
But than I get a really long error when I press the button, which should remove the image.
I hope you can help me out.
-Lukas
removeFromSuperview is your way to go.
car.removeFromSuperview()
Methods to manage the view hierarchy are documented for UIView.
I'm trying to disable scrolling in a UITableView when editing a UITextField embedded in a UITableViewCell.
This is just to prevent the cell from being scrolled out of sight when edited (and also to avoid some related cell "Recycling" problems).
While googling around I've seen that somebody suggested the obvious:
tableView.scrollEnabled = NO:
or even
tableView.userInteractionEnabled = NO;
This does not work though (at least for me... iPhone SDK 3.0, tried on simulator)
I set these properties to NO, I even check by logging that the properties are set to NO, but the UITableView keeps on responding normally to touch events.
And it also happily scrolls.
I wouldn't be that worried if somebody on the net were not claiming that this actually works.
Am I missing something?
Or is the only alternative subclassing UITableView to make a functionality available in its superclass (UIScrollView) work again?
Did you try using
self.tableView.scrollEnabled = NO;?
I've often tried that code from the web didn't work, simply because of a lack of the prefix self. I just tried this out without a problem.
I don't know if this work when turning it on and off dynamically. It does at least work for permanent settings when initializing the object...
If you're using UITableViewController, you also have a tableView property, with no casting needed. This works for me:
self.tableView.scrollEnabled = NO;
Let me know if that works for you.
Did you try on storyboard unselect scrolling enabled?
I tried:
[(UIScrollView*)[self view] setScrollingEnabled:NO];
and it worked ([self view] is my view of the current view controller, i.e., a UITableView).
The thing is, I get a warning:
'UIScrollView' may not respond to '-setScrollingEnabled:'
In all honesty, the property is "scrollEnabled", but it works nonetheless with the aforementioned code!
So, the "right" way to do things, should be:
[(UIScrollView*)[self view] setScrollEnabled:NO];
Why it also works the other way, is confusing me...
None of these answers worked in my case. Table view kept scrolling ever though every scrollView was disabled.
Finally, I've found solution in here, claiming that UITableViewController does this "for me" whenever keyboard hides the UITextView being edit.
Solution is to inherit from UIViewController instead of UITableViewController and implement the required table functionality myself.
if you want to scroll only if its content is not visible then set:
yourTableview.alwaysBounceVertical = NO;
Here if your content is visible then your tableview will not scroll