I am writing a program in Xcode in which i work with a tableview. In this tableview in every cell there is a small image. Now i would like this image to become full screen when the user taps it. I know this question was already asked several times but either the answer was in objective c (I'm writing in Swift) or when explain in Swift it swift. If someone could help me and give me a other solution or translate the working answers to Swift I'd be so so grateful. That would be awesome.
Thanks a lot.
Here are the links to the answers which seem to work (regarding the number of upvotes or checks ):
Expand UIImageView to full screen from within UITableViewCell
FullScreen image through tap on TableCell's image
Make a new View in your storyboard. Make a segue from the cell to the new view then in the viewcontroller overwrite the prepareForSegue method. you have to pass the image to the new view.
This link could help: http://jamesleist.com/ios-swift-passing-data-between-viewcontrollers/
Related
I have a quick simple question for you. I have a tableview and want to add a button(which is a star image) to every cell. Thus in the storyboard I drag a button into my tableview prototype cell. I can see perfectly that there is a button in the main.storyboard in my cell but, when I run the app no button is appearing in any tableview cell. How can I fix this issue? I'd appreciate any help!!
You need to create custom class for tableViewCell, and with this class, you can add your button. It's similar like in this tutorial, just instead of images, you can add buttons. On youtube you can find some good tutorial as well.
I am trying to build this view: https://dribbble.com/shots/3812962-iPhone-X-Todo-Concept
We can see that when the user swipes up on a cell, rather than displaying a new view, the cell expands and displays more information. How can I achieve this in Swift? I use a UICollectionView to house all the cells. Thank you for your time!
So far I haven’t been able to find an answer on StackOverflow that helps with advanced animations like this. However, I think that once the cell is clicked/swiped up on, the cell expands and then a new UIViewController is presented.
There’s a handy CocoaPods library that may help you with this. You can check it out here. (https://cocoapods.org/pods/Hero)
So, I've laid out a UITableViewController with two prototype cells, and a view in the TableView's header area. In the header area, there are two views that each hold an icon and a label, Friends and Groups.
It looks all good in the Storyboard Editor, but when the screen actually loads, the images and labels in question are gone. I'm fairly new to iOS, so I haven't run into this before. Here are a couple screen shots to illustrate:
In the storyboard editor:
On the simulator:
Any thoughts? Thanks in advance for your help.
You've implemented the data source methods in your view controller, correct?
If not, UITableView will call a method that its data source implements: tableView:cellForRowAtIndexPath: from the UITableViewDataSource protocol, where you would return the cell to use, in this case the cell with the Identifier that you specified in your Storyboard.
We figured out that this was because the tableHeaderView of a UITableView is really weird about updating/redrawing. It's very difficult to get it to act in any sort of expected behavior.
Instead of using UIImageViews, we used UIButtons. The buttons seem to know how and when to updated and redraw themselves, so that worked.
Im kinda new to Stack Overflow so bear with me please. I am trying to design an iPhone app and I noticed a feature on Huffington Post app that I have been trying to replicate with a different style. I am confused on whether they are loading this as a html inside a webview, or if they are reproducing this programmatically on XCode.
I have looked at UI Picker and UI PopOverController and neither can replicate into that. Can someone give me some advise on what element I have to use in XCode?
Here are some attached screenshots
Based on what your screen shot looks like, here is my guess of what they did:
On the view which they bring up the "popover", they have a UITableView with custom UITableViewCell. At the right end of the UITableViewCell(the image with plus sign) is a button, and based on the position of the button, they can decide the position of the popover and direction of the arrow.
They used a custom popover control. Inside the popover, there is a UITableView take all the space.
If you wanna do the same thing, you will have to know
How to use custom UITableViewCell.
How to do popover on iPhone.
Delegation if you wanna the view underneath to react to what you click inside your popover.
I can provide more details if you need.
I am almost at the end of coding my kids educational application, woohoo!.
But... Im stuck on something.
When app loads i have my main view. It has 4 buttons for flipviews(each with ten views of content) and 4 buttons for character selection(an image that will follow you through every screen of content).
Problem is im unsure on how to link UIButton selection to UIImage display in multiple views. I want the user to choose a character button and then continue to the flipviews and in the views the image displayed should be the one that they have selected on the main view. So everytime they return to the main view they can change the character that will follow them around the app.
Any thoughts, help or code would be much appreciated!
Thank You
Alex
Make a new object, a subclass of UIImageView, which has a -setImage method. Once you set the image, then where ever you embed that object, it will display the same image. You could even have that subclass view have a score displayed next to it, or a name or other stats, so as you go from one screen to another, you have all that info follow you around with the image. No need to create labels in all the screens for global info like that.
In summary:
make a new subclass of UIView or UIImageView in Xcode using the New File... menu. You would do new UIView if you will have other items than just an image.
add methods that allow you to set the image, update text stats etc.
BONUS: you can make the class handle taps, so if a user taps the image, you could do something like provide help or run a cute little animation
embed that object in any screens you wish. Keep in mind that you can have that view be sized differently in each screen using transforms. Cool, no?
that's pretty much it!
Good luck!