Animations are retarding on device - objective-c

I have a problem. Animations (switching between viewControllers, scrolling tableView) on device are working with spurts but on simulator work fine. How to solve this problem?

I'm afraid there is no easy answer.
The only solution is to improve your code and make it lighter and more efficient.
I ran into such problems too and I had no other option but to make my module work better.
The first suggestion would be to check for memory leaks (this one helped me: http://www.friday.com/bbum/2010/10/17/when-is-a-leak-not-a-leak-using-heapshot-analysis-to-find-undesirable-memory-growth/ ). Fixing the leaks should give a little more memory to work with.
If you have this spurts on the first gen ipad... meh, it's so and so. but if you have them on the ipad2, then you really need to rewrite your code: use less elements, make less operations, maybe use some background operations to perform some threads so you can leave the main thread free to make the animations

Scrolling tableViews shouldn't be too big a problem since it has been quite efficiently designed. Did you implement the method heightForRowAtIndexPat: ? If so, and you have much data in your tableView, it gets extremely slow. In that case better use a fixed height or the table.

Related

Framework of choice for building smart histogram in cocoa touch

I'm familiar with the basics of objective-c and cocoa touch and I want to start now my first large iOS project.
I want to build an iPad app with a histogram like you know it from several photo apps where you can see e.g. the distribution of brightness in a picture. But it needs to be smart, i.e. scrolling horizontal, setting borders and pinching for zoom-in and zoom-out.
Is it possible to handle this requirements with iOS7 standard API or do I need a 3rd party framework like Core-Plot to achieve a histogram I described, and if so, which one would you prefer and why.
Thanks for your help!
Is it possible to handle this requirements with iOS7 standard API or do I need a 3rd party framework
It's certainly possible to do it all yourself with no help from anybody except the frameworks that Apple provides. Whether that's the best solution for you, only you can decide. I think these are the relevant considerations:
You seem to have some fairly specific requirements and it sounds like you may need fairly fine control over exactly how this histogram looks and works. These are good reasons to create the histogram yourself.
You're still fairly new to Objective-C, Cocoa Touch, etc. That's a good reason to look for something that's already written. You'll save a lot of time and frustration, but you may have to be a little more flexible in terms of what you're willing to accept; it's unlikely that anybody has already written exactly the thing you want.
I'd suggest taking a shot a building what you want, and if it turns out to be a bigger thing than you're ready to tackle, you'll at least have a better understanding of what's involved.
To get started, read up on UIBezierPath. All you really need to do is to create a view that accepts an array of numbers and draws the corresponding graph. Don't worry about zooming and scrolling yet, just make a view that draws the graph. Once you have that, you can read up on UIScrollView, which will give you the scrolling and zooming with almost no work.

Methods of Lag Handling in iOS (SpriteKit)

Hey I've been working my way through making my first app, and I've hit the first problem that I don't even know how to begin fixing.
I am making a SpriteKit game, and as I've been coding, performance has been slowly dropping. Clearly I am not handling lag well at all. (~20-30 fps on device)
The thing is though, I'm not sure how to tackle this issue. I am going through and trying to loosen the load on each frame, but..
Are there any methods of lag handling that most people use?
I tried setting up a timer system, so that I know how much each segment of code takes to run, but the data wasn't too helpful.
It doesn't even look like a specific segment of code is taking that long at all.
This is kind of a broad question I guess, but how should you go about lag handling in SpriteKit?

Does glEnable slow things down?

I'm just currently writing my various routines. What I am doing is at every routine that say needs blending, I enable blending at the beginning and disable it at the end. Is this a bad thing?
For example:
Public Sub DrawQuad()
GL.Enable(EnableCap.Blend)
GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha)
GL.Begin()
GL.End()
GL.Disable(EnableCap.Blend)
End Sub
I have this, but I might call this 500 times in the same go, which means blending will get enabled/disabled 500 times. Will this greatly effect performance compared to just enabling once, drawing 500 quads and than disabling?
Premature optimization is the root of all evil!
As bcrist pointed out in the comments, if you're looking to optimize your OpenGL code, do learn the programmable pipeline. It's faster, more customizable, less reliant on magical function calls, and generally more awesome.
In general, optimize your big problems first, then get specific.
The best way to find out the answer to your question is to profile your code. OpenGL drivers are implemented by the hardware vendors for each device. Yes, calling any function repeatedly when you could call it just once will cause a performance hit, but how does that stack up against the rest of your code?
The take home point is admittedly annoying - your question is misguided and the "answer" isn't going to answer your actual question about calls to glEnable. You should optimize many things before you start looking at small functions like that.
For example, once you get the rest of your design sorted out and you realize that grouping together certain drawing routines by glEnable is even possible in your program, much less doable without incurring more overhead than it eliminates, then you might look into doing something to get rid of them.

What is the best way to find code that is blocking your main thread?

I have a UIScrollView in which I am placing a bunch of views as you are scrolling. it is downloading images from an api end point. The issue is that scrolling doesn't feel as smooth as it should be. I know this is because mostly something is blocking the main thread. I have searched through the whole code and commented out any UI update code, but scrolling fast is still laggy.
Any pointers on what is the best way to find which part of your code blocks the main thread?
Instruments. There's abso-freaking-lutely nothing like it. Even apple's documentation on it mentions finding high-CPU related tasks.
Personally though, I recommend the Time Profiler. Of which, an excellent tutorial may be found here.

Expression Blend very sluggish with >1000 items

I've gone a bit crazy with a piece of XAML and have a lot of small shapes.
The designer has gone really sluggish - I was flicking through the options hoping for a 'don't re-render objects that have not changed' flag or similar to give me back a bit more control.
Couldn't find anything, but thought it was worth a post on here. Does anyone know of a way of speeding things up?
Thanks
Try using the various options in Blend to combine multiple paths/shapes into a single path. This will improve both your design time and run time performance.