subviews and performance issues in iOS - iphone

I have different view controllers and i linked them using insertsubview
There are atleast three levels of subviews for every screen the users sees.
I havent tested it on device yet.
I want to know whether this causes any performance issues
Also, is using NavigationBarController pop and push views better than addsubview and remove from super view.
(I dont want the back functionality of NavigationBarController and want a custom header. That is why i didnt use NavigationBarController)

This is an interesting statement :
I haven't tested it on device yet.
My advice is simple :
Test it on a device.
Only you know what your app does - you can't possibly think we can answer your question with so little information! 3 doesn't seem a very big number but I don't know what each of those views is doing so maybe it's an issue, maybe not.

Related

Problems with presenting views in Xcode

I hope you can help me with my actual problems with designing an iPhone-App in the latest xCode version.
Here´s what I find a bit strange:
I designed a new project with a Storyboard and a Navigation Controller. Then I placed Objects like UILabels, ImageViews and so on. No when I run the Project in the simulator (as well on the iPhone) I noticed the following: When the App loads all the in the View placed objects fall down from the top to take their defined place. It takes maybe the quarter of a second, but its clearly to see. It also happens on all other views initiated from the root view controller
So, what do I have to change that everything is at it´s fixed place without to fall down from the top at the start of the app?
I hope I described it good enough. Actually I have no idea what´s going on there. I hope you can help me to fix this "problem". I´ve written some small Apps before, but I´ve never noticed a behavior like this.
Got the solution: I´ve had to remove the animations on the main view... now it works proper! :-)

Convert Separate TableViewController and ViewController into UISplitView

I currently have an iOS application that was originally developer for the iPhone; it was then decided that it was going to be required for the iPad as well. However, there are not many changes to cater for this (only things such as layout, text size and a few others) - the app is just a bigger version for iPad in reality.
One of the things my app makes use of is a UITableView (with a custom UITableCellView). Each one of these then moves onto a UIView. In order to make it a bit more unique to the iPad, I would like to implement a UISplitView to combine these two, to make better use of the larger screen!
This application was handed to me from a previous developer. A large part (95%) of the UI was coded (and not done in Interface Builder). While I am picking up objective-c, there are still some things which throw me. Therefore, my question to you guys is: would this require a huge change in code if I was to combine my UITableView and UIView into a UISplitView? From what I have seen from playing around with the UISplitView, it doesn't seem so. However, because of all the rest being coded, I think the UISplitView will have to be, is that right? Or can I dump in an xib and string up the coded UITableView and UIView?
Final question, is there a tutorial anyone knows about where they have coded a UISplitView? All of them appear to be using Interface Builder.
I hope that is not too much information!

Tricky performance problem about UIButton's in UITableViewCell (iPhone)

I'm going to implement a view similar to the original photo app in iOS.
I created a customized UITableViewCell which has 4 UIButton in it. And it updates the button's image when the image array of the cell changed.
I worked hard to get the performance really satisfying. However, I found a tricky lag problem about it.
When I use my app normally, the scrolling is very smooth without significant lag. But if I keep the app (simulator) running on the "thumbnail grid view", and switch to other applications in Mac OS. After a while (maybe about 1 minute), when I switch back to the simulator, the scroll view gets stuck. It's hard to scroll it. If I click on something switching to another view and then switch back, everything is smooth again. So tricky.
I also tried the TTRemoteExamples which uses three20 to implement the grid view. It also gets stuck after switching between different applications in Mac OS (not in the iOS).
Then I tried not filling the customized cell with UIButton but 4 images. It didn't get stuck. So maybe the reason lies in the conflict between UITableViewCell and UIButton?
I don't know if it only happens on simulator or have potential performance problem when shipped to device (I haven't got the device to test on).
Apple's photo app will never be like this.
So I'm going to implement it from UIScrollView by myself to see if the problem is caused by the UITableView's mechanism. I still want to know the reason for the lag if anyone has come to it and solved it.
Sorry for my poor English, I hope you can catch my meaning.
Who cares what the simulator does, seriously. Let it fart magical evil fairies that hijack the world's financial system causing it to enter a world of collapse...oh wait, maybe it already did that.
Seriously though, look at using code like AQGridView. It's very stable, provides an interface very much like a tableview, and is used in many projects. You also avoid the nonsense that is Three20 going this route. It's win-win.
But remember, always, and I do mean always, care what your app does on a device, if it isn't doing the same thing on the simulator, don't worry about it, you shouldn't be testing on the sim 99% of the time anyway. Users interact with your app on their devices, not your simulator. :)
Referring to Subclassing UITableViewCell section in Table View Programming Guide for iOS,
I finally solved the problem by implementing my custom mimicking the way from the guide, without adding subviews to UITableViewCell.
Apparently, adding too many subviews, only 4 in my code although, caused the strange problem I mentioned above. So, NEVER ADD SUBVIEWS, especially those with UIImageView's in it, to the contentView of UITableViewCell or UITableViewCell itself.
Instead, keep data's in the customized UITableViewCell, and do every drawing related thing in drawRect, using -[UIImage drawAtPoint:] and -[NSString drawAtPoint:withFont:].
In fact, the Apple's guide has mentioned it. It's careless of me skimming the part.
However, I'm still curious about why, as I mentioned, it only occurs when you switch between applications in your Mac OS, not iOS. I don't know the reason indeed.

How to make UITableView work within TTScrollView?

I'm solving a problem how to make tableviews work within three20's TTScrollView. I have a project which I want to rebuild using three20 library. There is one module which allows user to flip through set of "pages", which contains table showing some list of data.
My problem is that when I rebuilt this module to use three20's TTScrollView, tableviews inside the scrollview do not work anymore. In particular, it cannot be scrolled and cannot select an item, because all touches are intercepted by the scrollview. I'm getting mad about this and cannot figure out how to make it work.
I'm able to make work either tableview or scrollview but not both (means tableview intercepts vertical dragging, while scrollview horizontal). It worked fine with UIKit's UIScrollview, so there must be a way how to do this, but simply cannot figure out how.
Please help, I'm struggling with it yet couple of days now, but cannot get over.
thanks much for any hint.
Matthes,
Unfortunately not many people here at SO help out much with three20 questions for whatever reason. You may have better luck asking the three20 google group (search for that on google).
First guess though without trying it myself: try using three20's built in table items such as TTTableTextItem or TTTableImageItem ...in certain scenarios with three20, he has built in code to ignore everything you write except for his own built in controls (which might be the case here, not sure).
You can see examples of how he creates tables with this code in the TTCatalog example app that you can find via www.three20.info

iphone application layout

I'm trying to get started with an iPhone application, I had a look around at other questions but i'm still sorta stuck so hopefully someone can help...
First thing is I'm totally confused with the whole view concept, I'm more used to visual studio so I'm going to use the term 'form' to describe what I have in my head.
I want to achieve a home screen in an application with say 9 icons (much like the iphone home screen) which each lead to a different 'form'. Each form may have a different function so say one might be a simple calculator, one might play a video etc.
How do I do this, its destroying my soul trying to do something so simple... If you guys even have any links to get me on the right track it would be greatly appreciated
I suggest you take a look at the Stanford iPhone Programming Course. If you don't have the time to look through it all, I reccommend at least Lectures 5 and 6 about Views and ViewControllers. The slides are quite instructive and they come with video presentations that should help you get on your way in about an hour.
Apple's samples are a great place to start. There are some simple ones that can show you how views and view controllers work.
Also, in Xcode, when you create a new iPhone app template, that template usually has enough code to display a view, and sometimes a flip-side view or more. Sometimes, you should stop reading, and do.
I had the same weird learning curve as you, as things don't initially seem to make sense but they do - and once you've got your head round them they make perfect sense trust me!
Your 'forms' are viewControllers in this M-V-C land, they control all the 'view' (which are controls or any object which can be seen) within them. Normally they are loaded from a Nib (design from the interface builder), but don't have to be.
The way I would go about your problem is to use a navigationController as the base to handle all of your view controllers.
A navigation controller needs a rootviewcontroller to start so this will be your desktop Viewcontroller. I'm not sure how you are planning to populate this but all the icons will need to be stored in some kind of array. I suggest you use a simple UIButton. When then button is pressed you then alloc and init and push the required view controller.