I have a UITableViewController and UITextView in one of the cells.
When a user taps on UITextView all the table moves up tableView.frame.origin.y = -88.
As far as I can tell UITableViewController forces the table to move up. Is there a way to prevent this kind of behaviour?
You cannot disable autoscrolling on the UITableViewController.
The best thing to do would probably be to use a UIViewController as a table view's delegate and datasource. Check this answer out.
iOS: Disable UITableView animation when keyboard shows up
Just use a UIViewController instead of a UITableViewController - and make sure it conforms to UITableViewDelegate and UITableViewDatasource protocols.
Related
I am trying to implement a UITableView and a UICollectionView (25 cells with buttons) in a single ViewController, is this possible.
What I am looking for, is when I tap on the button inside the cell, it will add the button name to the TableView.
If anyone knows of any examples somewhere or any information. I would be greatful.
You can do it. Just make sure that your ViewController implements both UICollectionViewDataSource and UITableViewDataSource. You will also need a UICollectionViewDelegate in order to detect when a cell is tapped.
On how to implement UICollectionView you can see here: https://www.raywenderlich.com/78550/beginning-ios-collection-views-swift-part-1
I've tried adding a UIButton to the cell's contentView, which wasn't getting called. Then I tried adding a touchesBegan method to the cell. It's not being called. The cell has it's background color being set, and I can see in the extrapolated view that XCode now provides that it's the topmost view.
Any thoughts as to why interaction might not be working?
I think answer lies into UICollectionView delegate methods and datasource, you don't need touchedBegun etc,
I guess you want to know which cell has been tapped. More codes will definitely helps.
In storyboard do this,
A viewController with UICollectionViewCell inside it.
Add UIViewController subclass in your project and make your storyboards viewController as its subclass.
Add UICollectionView subclass and make your UICollectionViewCell its subclass.
read upon this link http://www.raywenderlich.com/22324/beginning-uicollectionview-in-ios-6-part-12
I have a UISearchBar implemented into my UITableViewController, my problem is when I scroll down in my table view, the search bar acts like a cell and scrolls with the table, therefore disappearing. Is there a war to programmatically fix this?
I know there are similar questions on SO with this issue and I have exhausted all the resources provided in those posts.
Thanks
Sure, don't use an UITableViewController but use a normal UIViewController with UITableView and UISearchBar inside.
When you use an UITableViewController, its UIView is directly the UITableView. So every control and subview go in the tableView. For this reason you need to change strategy and use the way above.
I want to disable autoscroll to top. I tried both
tableview.scrollsToTop=NO;
[tableview setScrollsToTop:NO];
but that doesn't work.
Thanks
The automatic scrolling code resides in tableViewController, so auto-scrolling can't be disabled. Instead of subclassing from UITableViewController you can subclass from UIViewController and use a tableView inside it.
If you are willing to use UITableViewController itself, you can override viewWillAppear and don't call [super viewWillAppear].
I've got a UITableViewController that inserts custom UITableViewCells into a UITableView. Is there a way that I can put this UITableController/View combo into different views? I've got the behavior of the UITableView acting the way I want, I just want to use that UITableView in different UIViews (say a UIView with a UILabel above the UITableView and one with a UILabel below the UITableView).
I know I can make a UIViewController that has an embedded UITableView in it and have the UIViewController act as the UITableView's delegate, but then I would have code reuse (the UITableViewController logic would be in multiple UIViewControllers). Or am I looking at this problem the wrong way?
I want to somehow reuse the functionality of my UITableView in different UIViews.
Thanks
Yes, you can, simply instantiate (or get a reference to) the UITableViewController inside the UIViewController and call something like this:
[self.view addSubview:tableViewController.tableView];