Add text view and image view desirable place - iphone

I have create an iPhone quiz application .Some of the questions have question image and some have only text. I have take a text view for displaying question and an image view for displaying question image . But problem is that when small sized question is appear then there have big gap between question and image. But i want to set same distance for all sized questions. How can i do that. please help me to solve this .Thanks in advance.

Use the NSString method sizeWithFont:forWidth:lineBreakMode: to get the height of your text, and then just add that on to the y value of the image/text.

Related

Suggestions for a Crossword Board [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I am new to iOS, although I have been with the basics and now I am trying developing a crossword app. Any suggestion where to start.
What problem I am facing the most, is to develop the 15 X 15 checkered board. I thought of two possible solutions -
To put 15 TextFields in each 15 rows, and according to the requirement I am going to disable the textfields and add black background color. But also there are two question, since the a crossword box has a number to the upper left corner, how can I put it? And the second is is it going to affect my performance since there are so many text fields.
Another possible solution I have thought of is coding a the board with CGRect and CGContextAddRect to the specified positions. But I am having problem on how to interact with the CGRect, that is when clicked it will bring up the key board and user can type the letter.
Please help, I don't know to where to start from. Other solutions are also acceptable.
I would suggest a UICollectionView. This is similar to a UITableView but with multiple rows and columns. Each UICollectionViewCell should consist of a UITextField.
For the numbers, you could either do that statically, i. e. you do it in your story board (place a UITextField for each number, the remaining space will be the UICollectionView.
Or (what I would prefer, but requires more logic) you make a 16x16 board and the 0th section and every 0th row in a section will be used for the numbers, the rest is for the actual crossword.
A best way is to use UICollectionView is you are targeting for iOS6+ or AQGridView if targeting older versions. Every cell is eventually a UIVIew.
Having custom textfield might make things complicated. Use UIKeyboard and set delegate as your collection view. In didselectrowAtIndex show your keyboard. Any keyboard delegate will return you character which you can set to Label at that box
There are few advantages for this over textfield approach
1) You can easily customize UIView/UILabel as compared to UITextField.
2) Labels can have custom fonts and attributed strings .
3) It's difficult to hide cursor in UITextField. which shows an editing mode.
Cons: Need Keyboard settings for Label. (However you can overcome with alternative controls like pickerview)
Also, make sure that you don't store any values in your views. Always refresh view from your data-structure (A 2-d array of characters).
Just a grid of views with labels in them should work. You might think its a good idea to be able to enter each character in place but it isn't. The user will have t tap Ana square type, type on another square, type...
So if you use labels you can have a different UI that let's the user enter a string in now go and then you can put the characters int the correct labels.

iCarousel same images issue

In my carousel view after 7 images next image shows the first image , the other one shows the second image although they are different images. I mean after 7 images they start repeat images. I am sure it is coming different images. My images are buttons. When i click them they show detail view. In detail view they show correct images but in carousel not. Do you have any idea what causes that. Thank you.
It sounds like you are using the reusingView feature wrongly.
You can fix it by increasing numberOfVisibleItems, but that's not actually the right way to do it since it uses up more memory and slows down the carousel.
Paste your carousel:viewForItemAtIndex:reusingView: method into the question and I'll check it for you.

create fliping book with images

I want to create a application in which i required following function
create array of images in view and move like page turning effect orientation change then same view will execute. tap on image then zoom in or zoom out image.
double tap then upload bigger image from web-services.
on image when select part of image then open url of that image.
Try these Sample code
https://github.com/devindoty/iBooks-Flip-Animation
http://oleb.net/blog/2010/06/app-store-safe-page-curl-animations/
https://github.com/mtabini/AFKPageFlipper
AFKPageFlipper will help you with the page-flip-effect. The other questions: First, try to solve it self (zoom, ...) and if you have problem ask a new questions here.

UILabel and images in it [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I would like to show some text with an image. But I would like the text to flow around the image. How can this be done? I've seen I can add views to a label, but I think just adding an image and then text it will not work. Can you point me to the right way please?
The best way to go about this is to create a UI Label for the side of the image, then another UI label below the image - then calculate the height of the first label a word at a time from your original text, once you have gone past the height of the UIImageView put the rest of the text in the bottom UILabel.
If you would like some example code, please email me at kendall.gelner AT kigisoftware.com (I tried to look for a way to email or DM you, but could not find one on this site).
Based on your sample image, this would be a custom object that you would have to create as a subclass of UIImage ..or you could go the easier route just make it as a view in Interface Builder that you add as a subview.
An example of subclassing UIImage would be like creating a helper method:
#interface UIImage (Labels)
- (UIImage*)toSize:(CGSize)size withLabel:(NSString *)label1 andSecondLabel:(NSString *)label2;
#end
but you would have to then implement drawing it all by yourself.
Instead, I would probably say go the route of creating a view in Interface Builder that has:
(1) UIImageView
(6) UILabels
that you can use as a subview and then you'd set them to whatever values like normal in code.
I am not sure, but Three20 is the most powerful project that I have ever seen in Iphone to support text and stylesheet. You may want to take a look

Generate View for iPhone application using interface builder.?

I wanted to generate one fix view using interface builder, but the size of that view is exceeding the size of iphone screen,and I am not able to maximize screen. I wanted to show table view in that screen.
I did enabled scrolling but that didn't work,
Update 1:
Actually I wanted to show thumbnail image inside cell and i want to show 5 cell so 5 thumbnail image,those images are static. So which is a better way to achieve this ,interface builder or programming?
Hope this is clear enough.
Your question is not terribly clear, so this is the question that I am attempting to answer here:
You want to have a table view which has five rows, each of which has a small image.
Short answer: you can't do this entirely in the Interface Builder. What you can do is define your table view, including the "look," scrolling abilities, etc. And then in the same XIB file you would define the table cells (which can include your pictures, captions and what have you).
You then have to connect the two together programatically. Apple provide plenty of examples in the SDK on how to do this.