How do I get the items to refresh in the Flowcover example? - iphone

The Flowcover example code provides an OpenGL ES implementation of the coverflow effect. How can I refresh the images used in that example?
I have tried [view reloadData]; but that didn't refresh the images. What else should I do?

Could you elaborate a bit on where you want to refresh the images? Are you reloading a new set of images you want to display?
Note that there is a cache in the class FlowCover that you might need to empty. There is currently no interface to do just that so you might want to add the next method to the class DataCache:
- (void) emptyCache {
[fDictionary removeAllObjects];
[fAge removeAllObjects];
}
Remember to send setNeedsDisplay to the View after modifying any data it depends on.

Related

How to refresh a view when resuming from Multitasking?

I have an app which is targeted to iOS 4 and above.I have a custom view, which is having
1.Scroll view
2.Custom drawing inside scroll view.
Now when my app is resuming from background,I want to refresh/reload this scroll view.
setNeedsDisplay is not working here as it usually meant for loading custom drawings and here I want to reload my scroll view contents.
Thanks in advance.
If I understand your question correctly, setNeedsDisplay does not work for you in this case because you need to "reload" the data that the UIScrollView handles before doing the redraw.
If this is right, I would define a method in your controller that does the reloading part; then, I would call this method from applicationDidEnterForeground or applicationWillEnterForeground; the reload method will need to call setNeedsDisplay after reloading the data.
I am sorry if this answer seems very generic to you. If you explain more or post some code, I can try and be more specific.
Have you tried redraw inside viewDidAppear?
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[yourScrollView setNeedsDisplay];
}
setNeedDisplay calls the drawRect which is repainting operation. If you want to refresh the content only simply create one method in viewController and notify this method using performSelectorOnMainThread if you created new thread whenever thread complete (or you receive Data).

iOS ViewController After Load Method

I'm trying to find a method thats called once everything has been loaded and displayed. The reason I want to do this is because I have some images that take some time to load in so instead of showing them a black screen I want to show a loading page and then call a setup method.
However the only methods I can find are called before the views come into view...
I am probably being really dumb..
Any help would be great.
Disco
You can use
- (void)viewWillLoad;
and
- (void)viewDidAppear:(BOOL)animated;
to do what you need.
How about
- (void)viewDidAppear:(BOOL)animated;

Pull to Refresh (ios)

I recently implemented pull to refresh here: https://github.com/leah/PullToRefresh. It kind of works however it gets stuck with a spinning activity indicator. Their is also no text to the right of the arrow. What am I doing wrong? Thanks!
Without code there's not much anyone can say, but maybe try a different implementation of Pull To Refresh, like the enormego (EGO) version, the code is at github, here
It's used in the Facebook app so it definitely works.
Apple has introduced UIRefreshControl in iOS6. You can integrate it in your UITableViewController using
- (void)viewDidLoad {
[super viewDidLoad];
// Initialize Refresh Control
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
// Configure Refresh Control
[refreshControl addTarget:self action:#selector(refresh:) forControlEvents:UIControlEventValueChanged];
// Configure View Controller
[self setRefreshControl:refreshControl];
}
the refresh: method will trigger the update and you can stop it in your API callback using:
[(UIRefreshControl *)sender endRefreshing];
I am new to iOS development and I was trying to implement the pull to refresh in iOS 6. Well looking for a solution, I stumbled across this blog post and found it to be very helpful, http://www.intertech.com/Blog/Post/iOS-6-Pull-to-Refresh-(UIRefreshControl).aspx. It lays out the steps to implementing pull to refresh in a way that is easy to follow. Anyone looking to do this themselves in iOS 6 should check out the blog.
The UIRefreshControl is only useable with a Table View currently. There are a few steps to follow to successfully add a refresh control:
1.
Create a callback method to handle your refresh logic. The callback method should be invoked when a user pulls down on the table view. The signarture of the method should take one parameter: a pointer to the UIRefreshControl.
Note: Steps 2-4 are all done within the Table View Controller’s viewDidLoad method.
2.
Instantiate the UIRefreshControl with a basic "alloc/init".
3.
Connect an action to the refresh control to invoke your callback method when the ValueChange event is fired.
4.
Add the refresh control to the Table View Controller's "refreshControl" property.
I prefer the EGO implementation than the leah one because it does not require a subclass of your view controller. The original EGO one in github is a bit of a mess with no .gitnore file and lots of .DS_Store files added unnecessarily. Take a look at some of the many forks and pick one.
The "emreberge" fork looks like a good version, better file organisation and documentation too!
https://github.com/emreberge/EGOTableViewPullRefresh
I found this library very useful, fancy and up-to-date: https://github.com/Yalantis/Pull-to-Refresh.Rentals-iOS
(Recommendations from other answers seem old and not maintained)
Now, with newer versions of iOS than the above stated iOS 5 you can use: UIRefreshControl.
There is a really good tutorial on creating your own custom pull to refresh for your iOS Application: http://ios-blog.co.uk/tutorials/how-to-add-a-custom-pull-to-refresh-in-your-ios-application/
You can use : https://github.com/ngocbinh02/httablekit
Support iOS 5.0 or later
Pull to refresh tableview
import <HTTableKit/TableKit>
....
//like UIRefreshControll
[tableview setPullToRefreshControlType:UITableViewRefreshControlTypeSystem];
[tableview setPullToRefreshModeEnable:YES beginHandler:^{
// to do here when pulling to refresh
}];
Dismiss pull to refresh tableview
import <HTTableKit/TableKit>
....
[tableview dismissPullToRefreshEndHandler:^{
// to do here when dismissing
}];
Here's our tutorial on Custom Pull-to-Refresh controls, with code for Objective-C and Swift: http://www.jackrabbitmobile.com/design/ios-custom-pull-to-refresh-control/
To add additional text or images, as you mentioned, add them into self.refreshLoadingView in the setupRefreshControl or scrollViewDidScroll methods (from the tutorial).
Let me know if that helps!

how can i do multitask in one view?

i have one view ,in that i want to show table view with mapview .
my problem is how can i process in both thing same time. i want to show this things same time so speed problem not come.
for more info i added image which i want to show.
You'll want to look at multithreading my friend.
Have your methods that manage the tableView run in one thread, and the map methods in another.
For instance, in your viewDidLoad:
[self performSelectorInBackground:#selector(downloadMap) withObject:nil];
[self performSelectorInBackground:#selector(downloadTableData) withObject:nil];

Custom view transition in OpenGL ES

I'm trying to create a custom transition, to serve as a replacement for a default transition you would get here, for example:
[self.navigationController pushViewController:someController animated:YES];
I have prepared an OpenGL-based view that performs an effect on some static texture mapped to a plane (let's say it's a copy of the flip effect in Core Animation). What I don't know how to do is:
grab current view content and make a texture out of it (I remember seeing a function that does just that, but can't find it)
how to do the same for the view that is currently offscreen and is going to replace current view
are there some APIs I can hook to in order to make my transition class as native as possible (make it a kind of Core Animation effect)?
Any thoughts or links are greatly appreciated!
UPDATE
Jeffrey Forbes's answer works great as a solution to capture the content of a view.
What I haven't figured out yet is how to capture the content of the view I want to transition to, which should be invisible until the transition is done.
Also, which method should I use to present the OpenGL view?
For demonstration purposes I used pushViewController. That affects the navbar, though, which I actually want to go one item back, with animation, check this vid for explanation:
http://vimeo.com/4649397.
Another option would be to go with presentViewController, but that shows fullscreen.
Do you think maybe creating another window (or view?) could be useful?
While I cannot completely answer your question without doing some more research of my own, I can help a bit:
-In order to get the view of a UINavigationController, you need to take a screenshot. The easiest way to do this is by grabbing it into a UIImage:
UIGraphicsBeginImageContext(self.view.frame.size);
[[self.view layer] renderInContext:UIGraphicsGetCurrentContext()];
UIImage* test = UIGraphicsGetImageFromCurrentImageContext();
UIImageView* view = [[UIImageView alloc] initWithImage:test];
UIGraphicsEndImageContext();
I am not sure if you can render a GLContext (not familiar on the phone) into a CGImage, but I would do something like that (and init a UIImage from that). I would prerender every frame of the animation you are trying to do and slap it into an UIImageView using the animation stuff provided within. That is, if your animation is simple enough. Otherwise, it might come down to writing your own animation function :-/
I have just put together a transition class to implement your own transition animation in OpenGL ES.
Feel free to read about it here
There are two example transitions in the project, feel free to add you own to it.
I think the function you might be thinking of is http://www.opengl.org/sdk/docs/man/xhtml/glCopyTexImage2D.xml ... you set the viewport to the texture size and then draw as usual, then do glCopyTexImage2D to copy the scene onto a texture.
or you should look into FrameBuffer Objects. The default OpenGL template in XCode uses these. Just generate the example project to see how those work.
I recently write some transitioning animation betweeen view controllers like you. If you want to get any extra info from the invisible view, you can try delaying the transition like this :
- (void)animationFromModalView:(UIView *)modalView toMasterView:(UIView *)masterView
{
[masterView setNeedsLayout];
[masterView layoutIfNeeded];
[self performSelector:#selector(delayAnimationFromModalViewToMasterView) withObject:nil afterDelay:.1f];
}