Scroll horizontally UIScrollView inside UITableViewCell - ios

I know this issue isn't new and there are many similar questions like this on this site. I've checked most of them but cannot find the answer.
I have a UITableView. Inside each UITableViewCell, I insert some of subviews (same level). One of subviews is a UIScrollView that I use to add some UIIMageView to scroll horizontally. The ScrollView is the bottom subviews (other subviews are above this ScrollView). I've made a test project and pushed to GitHub: https://github.com/lenhhoxung86/PageControlDemo.
The project works file and I noticed that delegate method: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath is not called but it's just fine.
However, when I moved this code into my real project, it doesn't work and the delegate method of tableview (didselectRowAtIndexPath) is actually called.
Can anybody help me fix this? I'm going to insane for this issue. Following is picture captured on my test project

Finally I found the cause. In my test project, I used a Xib file created when I created a custom class of UITableViewCell. The view object is kind of class UITableViewCell by default. In my real project, I created custom class UITableViewCell first then created many Xib files so that I can load them when I need. By default, these View objects in these Xib files are kind of UIView. I re-created Xib file that belongs to class UITableView by default then it works. I have no idea how to convert existed Xib file with object of UIView type to UITableView.

Related

UICollectionViewCell Overlay View

I have a UICollectionViewCell with .xib.
Here is the Structure of the xib file
As you can see every element at the same level and 3 image views and a single button. But at run time there is a UIView in front these elements.
UI structure at runtime.
I need to understand why this is happening and what is the solution. Because of this overlay UIView clicks events not pass down to the button.
Problem was I was using UIView in the XIB that created by default when creating a xib file. Instead of using that I tried with UICollectionViewCell element as the parent and it worked for me.

Connecting label to UITableViewCell

I've created several tables in the past but I believe it's something with the way I'm doing it that Xcode doesn't like this time.
I have several xib files with a UIView inside. These together creates a slideview like snapchat.
In one of these xib files I have a UIView. In this I have a UITableView and a UITableViewCell. I have set up a prototype cell with an identifier "cell". I've set up the delegate and dataSource as I usually do.
I made a UITableViewCell class and set up the class for the prototype cell.
Here's where the trouble is:
I wanna connect my labels on the cell to the UITableViewCell class and make IBOutlets. But Xcode doesn't let me do it. It simply doesn't connect them.
Any suggestions on why I can't do it or if there's a way around??
Change class of your UITableViewCell to your custom class in xib. (in utilities section,there is option called custom class)

UICollectionview and/or UITableview cells not selectable until after view scrolled?

For every collectionview and tableview within my app, none of them are recognising the selection of a cell unit AFTER the table or collection has been scrolled a little?
This only happens within this current app, no different methods have been used, no collection/table subclassing etc. All collection views and table views are implemented with all relevant dataSource and Delegates hooked up and implemented etc.
As this is a common thing will all my tables, I'm wondering if it is a setting within the project that is causing this.
If anyone has experienced and previously solved this issue, I'd appreciate any help.
Salient points that may be relevant -
-All collecitonviews / tableviews are set up on storyboard.
-All cells are added directly to table/collection within storyboard and cell view configured using their own class files.
-Deployment target 7.0 for iPhone only
-All tables/collection cells are loading fine, everything looks fine with no crashes... just that the tables need 'woken up' so to speak?
Thanks in advance,
Jim
I've had similar issue, and I fixed it by subclassing UICollectionViewCell/UITableViewCell and setting selected property to NO in prepareForReuse method.
- (void)prepareForReuse
{
self.selected = NO;
}

Unable to use Static Cells in UITableViewController

I need to use static cells in my app. I am using Xcode 5 and testing thins on iOS 7 simulator (iPad).
I dragged out a new UITableViewController in storyboard and set the tableview's cells to be static. Then I added a Label to the first cell to check if static cells are working. I ran the app and I got blank cells (dynamic form).
Then I added a class that implements the datasource and delegate methods of a table and attached it to the controller in storyboard. Yet, nothing happened. Finally, I embedded it in a UINavigationController and still, I get plain blank cells like the one below:
Could you tell me whats going wrong here, i.e., why wont my static cells show up!?
Regards
if you use static cells you dont need the datasource. so delete all methods that belongs to datasource, such as cellForRowAtIndexPath. After deleting the methods your label should appear.

Strange error when adding items to prototype cells in storyboard-IB

I have quite a large project (~20 scenes). One of which is a TableViewController with a custom UITableViewController class. I have given the cell a reuse identifier, and added a label to it. When I try and Ctrl+Drag the label to the UITableViewController header file to create an outlet, I get the following error:
error: Illegal Configuration: Connection "tableInfoView" cannot have a
prototype object as its destination.
What is this? Am I overlooking something obvious? Or do I need to create a custom cell class and drag the outlet to that? If so, how do I then specify the data which is displayed uniquely for each cell from the UITableViewController?
In fact you can't just make an outlet from a dynamic cell prototype in the UITableView delegate view controller.
You'll have to subclass UITableViewCell and then attribute this class to your prototype.
Then you can Ctrl-Drag from the Label to the UITableViewCell subclass header file.
Finaly you can access to this outlet in the delegate code after having imported the UITableViewCell header file in it.
This is documented by Apple there at "The Technique for Dynamic Row Content" section.
or you could give the label a tag (e.g. 100) and use
myLabel = [myTableView viewForTag:100];
to get the label
I had the same error myself. Just to add one more potantial root cause for future readers:
In my case I copied a control (a Button in this case) from one prototype cell to the next and the action still referred to the neighbor cell. My table has several different prototype cells.
The fact, that it acutally was a proper subclass of UITableViewCell which was properly connected to the prototype cell made it difficult to actually see the mistake.
Tag the label and you can reach the label anywhere in the viewcontroller like with viewWithTag from the table view.
UILabel *destinationLabel = (UILabel *)[self.tableView viewWithTag:1];
destinationLabel.text = #"Label Destaination";
I faced the same problem but later it turned out that it was just a silly mistake.
I mistakenly dragged the label from Cell to my controller's #interface
This could be your problem too. just cross check once.
Set the right reuse identifier used in .m file in the Storyboard for the Prototype cell.I had the same situation and this helped me
After doing every thing right if problem still exist then just removed all outlets and rejoin them carefully and it worked very fine for me.

Resources