Why can't I edit multiple dynamic prototypes in UITableView? - ios

I'm creating a Table View in Interface Builder (Storyboard). I'd like to have a couple of different Dynamic Prototype cells with different sets of Labels and Images in them and so on, and I can give them different reuseIdentifiers so I can pick which ones I want at runtime.
In Interface Builder, I create several Dynamic Prototype cells in my UITableView, which is controlled by a UITableViewController.
In the first cell, I drag and drop in various views and so on.
In the second cell, IB will not let me drag any views into it? I can resize the second cell vertically, but can't put anything into it at all, either by dragging into the cell or into the object graph in the left-side bar.
If I copy and paste the first cell, a second Dynamic Prototype will appear with all of the same contents, but I won't be able to modify the copied cell (can't add or move subviews). However--and this is strange--I can select the constraints and modify their values to resize and shift objects in the second cell.
As a note, running XCode 5-DP3. Tried restarting it (didn't expect that to help, and it didn't). Otherwise, unsure what to try, and unsure if I'm doing something very braindead, or if this is a bug I need to report to Apple.
So, am I crazy? Has anyone experienced this/can anyone recreate this?
EDIT:
After further testing, if I stick a big UIView into the first cell, and then copy that cell, I can edit inside my added view. (Does this make sense?) I can't edit anything that lies within the second UITableViewCell, but if it contains a UIView copied over from the first cell, I can put new views into that view and move them around and so on. Super-strange.

For the sake of posterity, I'm answering my own question:
The way I solved this was to take a UITableViewCell object from the Object library and drag it onto the UITableView. Sounds simple, right?
The problem I was running into was only if I copied existing dynamic prototypes through Cmd+C & Cmd+V, or by incrementing the number in the Attributes inspector for the table view. The Storyboard Editor wouldn't allow me to modify those ones.
Dropping in new cells from the Object library let me tweak them all separately.

XCode 5-DP6 solved issues with not abling to resize cell's subviews.

Related

UIImageView Not Deleting From UITableView

I have created a UITableView with a cell inside. Inside this cell view, we have a Content View, and in that, I have subtitle text. This is all in the storyboard. I wanted to have an image right next to the cell, so I put an image and chose a picture.
The image turned out really small, and I couldn't even make it bigger - it was that small. So I put another image view that I created in the view and plopped it into the tableView. Then I try to delete the first tiny image view. It doesn't delete.
When I try to move it out of the Content View, it duplicates itself. When I try to drag it to the view and out of the Content View, it sends a duplicate version. So I tried to change the cell type from subtitle to custom, hoping that everything in the Content View would disappear and I can put it in again.
Then, Xcode crashed. I tried again with changing it to custom, but it crashed again. I didn't put the crash report because it is very long but tell me in the comments if I should put it, and I will edit this question to put it in. Tell me if there is any other information you need.
Thank you in advance!
UPDATE:
I deleted the whole cell. I realized that when putting a picture in the attributes inspector of the table view cell, it makes the picture either really big or really small. It doesn't allow me to resize the picture or move the picture without randomly duplicating it. Does someone know why this happens?
If you want to customise the size of your image, you can do so very easily by creating a UINIB file and then customising the look of your cell in the new file created. You can do so by creating a new cocoa touch class of type UITableViewCell and then select the create XIB file checkbox. Then you will see a similar to main.storyboard layout which works exactly like the main.storyboard and the difference is that it is specifically for the table cell. Make sure you register the UINIB with the table view so that you can control the data that shows up in your cell. I hope this helped!

Static table cells with detail

I'm trying to make an iOS 'information' or 'guide' app in Swift. I wanted to utilise the Master Detail template so that when the user clicks a cell it will take them to a relevant ViewController with either basic text labels or a PDF file.
From what I understand, Dynamic Cells can be dynamically changed whilst the app runs however I want to set static cells from the storyboard (or programmatically) and their relevant content/PDF files so the user can view each one. I don't want any "new cell" or "editing" functionality.
How can I make this work? I would post my code so far but it's almost identical to the Master Detail template so I don't see any use. I know this is quite a vague question but I need help and don't know where to start.
Any help will be so appreciated!
A static table cell can entirely be created via storyboard. In the storyboard once you add a tableviewcpntroller you can prototype call added to it.You can add as many prototype cells to your table ( not necessarily every one should have common layout). After all cells are added you can assign individual tags to the cells if you need identify these cells from your code.You can add segue from each cells to move to different page.
Let me know if something more is needed.
In Interface Builder set the Content of the table view to Static Cells.
Drag as many table view cells as you need into the table view.
In the controller create IBOutlets for the labels and the other UI elements.
Connect the outlets in Interface Builder.
Rather than using the datasource methods assign the values directly to the UI elements via the outlets.

Access child views in custom UITableViewCell

Background:
I am trying to create a table view with around 4 types of different cell layout.
At first, I considered using static table view to solve the issue since the number of rows are somewhat fixed (nor more than 10)
But, after some thinking, I decided that I don't really want to be tied up to the UITableViewController. Thus, I tried to implement it with dynamic table view.
Question:
After I create 4 prototype cells, I found out that I'll need to access the child views in cell (to update their value). But the only possible ways I know seem to be:
1. Create a subclass for each prototype cell, and create `IBOutlet` to the child views
2. Assign `tag` for each child view for later access
But I don't really like these two methods...
The first one is too cumbersome, and the tag in the 2nd solution does't seem to be very sepcific (access the child view by just some magic number..)
So, I would like to know:
Is there any better practice for implementing this kind of
tableview. (multiple cell prototypes, and fixed row numbers)
Is static table view a better way to do it? If yes, will there be
any limitations when I am tied up to UITableViewController?
For example, if I need more complex UI, and decide to add more views on to it, will UITableViewController be less flexible than UIViewController
Thank you so much!
If the cells are very similar but with different layouts they could share a common UITableViewCell subclass provided the class doesn't need to know the layout it is in just configure the available outlets.
If the code does need to be aware of the layout used then it is probably best to make them separate subclasses.
For Swift use is or as? to confirm the correct subclass for the cell (for Objective C it would be the isKindOfClass method).
1.You do need to subclass the UITableViewCell if you want to access his IBOutlets.
In order to distinguish between the cell just use isKindOfClass
2.It depends how different your cell are from one another. If they have slightly different structure you might want to consider lodging the elements in cellForRow. Try to take a look at the built in structure cause it might save you some subclassing.
These structures have built in parameters such as: image,text etc.
Their structure is more strict though
Theses are the available types:
UITableViewCellStyleDefault, // Simple cell with text label and optional image view (behavior of UITableViewCell in iPhoneOS 2.x)
UITableViewCellStyleValue1, // Left aligned label on left and right aligned label on right with blue text (Used in Settings)
UITableViewCellStyleValue2, // Right aligned label on left with blue text and left aligned label on right (Used in Phone/Contacts)
UITableViewCellStyleSubtitle // Left aligned label on top and left aligned label on bottom with gray text (Used in iPod).
I don't really understand why you want to use tags?

xamarin.ios - adding views to tableitem programmatically

I'm building an interface in codes from scratch (there's nothing in XIB file). I'm adding a tableitem that consists of some cells and those cells contains one or more views (UIButton, UITextField, etc.)
The problem is none of the items are clickable/editable! When I click TextFields or Buttons, nothing happens! No highlighting, no cursor changing nothing at all...
What I'm missing here?
Also constructed the cells programmatically. I am adding controls directly to the UITableViewCell.
One possible issue: some of your views (may be ContentView or the UITableViewCell) hides the controls from manipulation. You should set that [UIView].userInteractionEnabled to false. You can also try to implement touch listeners to your views to recognize which one hides your controls.

drill down UITableView using storyboard in iOS program

I'm trying to develop an iOS app that has drill down UITable View. I got a drill down table view tutorial, but the number of UITableViews is static. What I need is a dynamic one. My requirement is simple. I need to access an FTP Server and get the directory hierarchy (I guess I need to store it in NSDictionary or in an xml file) and display the content in the UITableView. If it is a text file, I need to display it in some view, otherwise I need to display the selected folder's content in the same UITableView, and it goes on till the bottom of the directory hierarchy.
I need to use the storyboard.
I've had to make a something very similar to what your talking about in a previous application I worked on.
In that I created table views inside of table view cells with a button at the top to expand and collapse the view using the cell height.
This worked pretty well but since then I've found the best way to simply programmatically add ui elements to either your table view cells or view.
In both cases I created a management system using parent child architecture to hold your information.
I hope this puts you in the right direction :)

Resources