Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

n00bz0rd2

macrumors member
Original poster
Mar 26, 2010
41
3
2 questions here.

Firstly:
In my app, there is a detail page and all the info is gathered from a plist. In my nib there are 2 UITextViews to display the data.
My main issue is spacing. As the amount of text in each UITextView is going to change for every category how can I set it so that the bottom UITextView has the same amount of gap/spacing after the first one, depending on the content of the first.

To make things a bit clearer:
UITextView 1 has 5 lines of text and UITextView 2 has 10 lines of text.
The gap between each view should be, for example 10px.
This is easy to setup in IB

Now, if UITextView 1 has 10 lines of text and UITextView 2 also has 10 lines of text, if I build it the text will overlap. How can I apply the 10px gap?

Kinda like margins in HTML/CSS

Hope this is clear!

Secondly:
Since I am very new to iPhone programming, I do not entirely know how to use a SearchBar. How can I setup a search bar using a plist?
 
Now, if UITextView 1 has 10 lines of text and UITextView 2 also has 10 lines of text, if I build it the text will overlap. How can I apply the 10px gap?

Kinda like margins in HTML/CSS
Since UITextViews are subclasses of UIScrollViews, if the content doesn't fit within the view, it is expected to scroll. You could try and do some fancy figurin' based on how much text and then setting the contentSize and frame of the TextView so that it doesn't scroll. Then you could set the frame's origin of the second TextView based on the origin and size of the first TextView. But you might be on to a better solution with that HTML/CSS reference. Maybe setting up a UIWebView to contain the content that you're now putting in the two TextViews is a way to go.

Secondly:
Since I am very new to iPhone programming, I do not entirely know how to use a SearchBar. How can I setup a search bar using a plist?
Please elaborate. What problem are you trying to solve that you feel a plist is the solution?
 
Since UITextViews are subclasses of UIScrollViews, if the content doesn't fit within the view, it is expected to scroll. You could try and do some fancy figurin' based on how much text and then setting the contentSize and frame of the TextView so that it doesn't scroll. Then you could set the frame's origin of the second TextView based on the origin and size of the first TextView. But you might be on to a better solution with that HTML/CSS reference. Maybe setting up a UIWebView to contain the content that you're now putting in the two TextViews is a way to go.

Could you explain a bit more about using a webview? Never used one before. I've just had a quick read about WebViews. Would that mean the user would always need to be connected to the internet in order for the content to be shown?
Also, can CGRect be used to tackle this?

Please elaborate. What problem are you trying to solve that you feel a plist is the solution?
Basically, my app is a recipe app. So the plist has recipes inside of it. How can implement a search that searches by keyword? So for example, if I type in "chicken" it will list every instance of chicken.
 
I managed to get my spacing issue sorted with the use of frames. Works like a charm.
The search function is still alien to me.

Another problem: if I have the names (no extensions) of images in the plist file. How can I display that image?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.