I tried to add images with the size of 32 by 32...it worked but it shows me only the first image for all the objects on the table view... In other words only image for all the other objects
You need to implement this in the tableView:willDisplayCell:forTableColumn:row delegate method. You should probably read the TableView Programming Guide before going further.
Related
Essentially what I have is a view controller full of auto-resizing UILabels and what I am wanting to do is to have it resize the view so it will allow me to scroll through all of the text labels without cutting them off. It shows the first three fine but the last one always gets cut off.
I am using Storyboards with AutoLayout and have not modified anything in code besides the UILabels. I have already tried using a TableView, but did not like the feel of that and had trouble storing my custom objects in arrays.
So here is what I did,
I got rid of the UIScrollView and replaced it with a UITableView with three NSMutableArrays. To get the UITableView to work I first had to load three NSMutableArrays with dummy data and then I had to call my object and print out an NSLog statement or else the app would crash. Finally I reallocated the array and put in the correct data. After all of this it worked.
I'm trying to make a large UIScrollView with various UI elements on it which is larger (wider) than the iPhone's screen.
I'd like to be able to lay those elements out in a UIView, and then load that UIView into the UIScrollView. This way, I can clearly see in Interface Builder what I'm doing with that large view.
How can I do this, with Storyboards active? I'm trying to do something similar to the #2 example here, but using Storyboards:
http://agilewarrior.wordpress.com/2012/05/18/uiscrollview-examples/
See if this tutorial from Ray Wenderlich helps, which goes into pretty good detail about UIScrollView :
http://www.raywenderlich.com/10518/how-to-use-uiscrollview-to-scroll-and-zoom-content
If you're doing layout programmatically, please take note of this important comment:
You might ask why we don’t do all of the above in viewDidLoad, and you’d be right to ask. The reason you can’t is that the view size isn’t definitely known until viewWillAppear:, and since you use the size of scrollView when calculating the minimum zoom, things might go wrong if we do it in viewDidLoad.
Good luck!
I am using a UIPageViewController in my app to display number of images (1024x768 size). Is it ok to make array of UIViewControllers each with his picture and in set appropriate for each page? Maybe if you get like 50 pictures it will crash? At the moment I store images in Documents folder so I can remove images from view controllers that are not on screen
This wouldn't be very efficient, you'd be much better off doing the same thing with UIImageViews. Even then you have to be careful. Probably the best way to handle this would be to using image views and deallocating them when they go more than one image width out of the screens bounds. Then of course reallocing when the image in question is the next image in line to be displayed in either direction.
EDIT: It looks like you can use the following UIPageViewController Datasource methods to set which view controller do basically have queued and waiting to the right/left. Using these you should be able to only allocate 3 view controllers at a time.
– pageViewController:viewControllerBeforeViewController:
– pageViewController:viewControllerAfterViewController:
Then you can use this to set the initial controller:
Set the initial view controller using UIPageViewController's
-setViewControllers:direction:animated:completion:
The sentence below is quoted from Apple's documentation and is leading me to believe that the controller may be able to only load the necessary view controllers into memory on its own.
View controllers are either provided one at a time (or two at a time,
depending upon the spine position and double-sided state) via the
setViewControllers:direction:animated:completion: method, or provided
as-needed by the data source. Gesture-based navigation is enabled only
when a data source is provided.
I have an app that basically can be used to download, upload, and manage photos from various web services.
I want the image list view to look like the iOS Photos app but not quite sure what the best way to do that is.
I was thinking I could use NSMutableArray and subclass UIScrollView to create that functionality from scratch but I'd really like to use NSFetchedResultsController because some of the data related to the images are dynamically/asynchronously updated/inserted/deleted in Core Data.
Right now I've setup something pretty hacky.
I created an separate Core Data entity to hold relationships to 4 photos in each managed object and I made UITableView loop through them. Then cellforrow delegate would loop through the 4 photos in each table cell. This approach sucks because it's hard to delete and insert photos dynamically and I have to reconstruct relationships and reload the table each time an update is made.
I've looked at some other libraries that do this but I really want to understand what the most simple and efficient way to do this is.
If you are referring to the tile view, you can duplicate that using a UITableView or a UIScrollView. If you want it to side scroll then a UIScrollView is the starting point.
If you want it to scroll vertically (which I recommend on iPhone) then use a UITableView with a custom UITableViewCell.
As for the Core Data side, you are probably coming at this incorrect, you are trying to store UI state information (how many photos are in a cell) in core data. Core Data should not care about how many images are in a cell.
UITableViewCell
To use a UITableView you would create an array that contains all of your images. You can then determine how many rows you need by dividing that array by the number of images per row.
From there you should subclass UITableViewCell and pass in the 4 images for that cell to draw. Then it is a simple matter of adding 4 UIImageView instances to the custom cell and setting the images.
UIScrollView
For a scrollview you crate a UIImageView for each image and then add them as subviews of the UIScrollView. You would then set the frame of each UIImageView so that they are displayed in a grid.
If you find you have more images than you can hold in memory at once then you will need to deal with tiling, effectively paying attention to where the user is scrolling and filling in (via moving the offscreen image views) ahead of the edge the user is scrolling towards. This is the same thing you get effectively for free with a UITableView via its queuing of cells.
I just did this with a UITableView - you are over thinking it with the relationships.
For my solution I created a UITableViewCell subclass has four buttons as properties.
In my cellForRow method I figure out which four images belong to that row and then set the appropriate image for the appropriate button.
My images are in an array in my view controller. I populate the array in viewDidLoad. Whenever I add or delete an image from the managedObjectContext I repopulate the array and then reload the tableview. Reloading the tableview will rearrange the images in the cell appropriately.
Scrolling is smooth and the only drawback I have run into is that I would like the images to animate to their new positions when I delete one, but I do not think that I'll be able to pull that off with this setup.
I think a very nice implementation is AQGridView.
It is easy to extends, has nice reordering (see the springboard demo) and it reuses the cell.
If you ever implemented a TableViewDelegate, you should be able to use it.
You should check out the Three20 photo viewer. The project is on github. Also, there's a nice tutorial for the photo viewer here
Hi can anyone let me know which control they have used for doing the scrolling.
I like that control very much.
http://www.youtube.com/watch?v=Ssa2k4RlYXs&feature=channel
Application is free to download. Help me to figure out which control is this.
Application URL: itunes.apple.com/us/app/xix-cwg/id353382539?mt=8
Help me out.
Control is inside: Schedule Tab in the application
Thanks in advance.
Regards,
Arpan
Most likely that video is just a UIScrollView. While it shares a lot of the properties of a UITableView you may notice that a UITableView is a subclass of a UIScrollView.
There are a number of ways to create that functionality. I recommend looking at the documentation for UIScrollView. You may be able to find some glue between a UITableView and a UIScrollView. If you decide to write your own UIScrollView subclass keep in mind memory issues. You will have to unload the "not visible" portions of the view if you are displaying a lot of data.
The UIScrollViewDelegate protocol has the scrollViewDidScroll: method that you can use to do custom view layout as the view scrolls.
You can use the contentOffset property to get the position of what is being displayed in the larger scrollview.
I think you will find its not that hard, once you experiment with UIScrollView. Especially if you aren't planning on do any zooming.