I’m new to IOS development, and I’m just trying to get my head around all the views. At first I have a UITextField which is one line and I wanted it to wrap. I was told to implement a UITextView instead – and that worked! I then had many lines of wrapped text.
The next thing I wanted to do was have horizontally scrolling pages. I downloaded apple’s page control example. In it many pages are created with a little text label. I altered this to contain a very long string, and replaced the UILabel type with a UITextView. However, it’s not word wrapping! The cause could be anything an I have absolutely no idea what it might be. Perhaps it’s inheriting some setting from something?
Any help would be much appreciated.
Edit – here is where the views are created:
- (void)loadScrollViewWithPage:(int)page
{
if (page < 0)
return;
if (page >= kNumberOfPages)
return;
MyViewController *controller = [viewControllers objectAtIndex:page];
if ((NSNull *)controller == [NSNull null])
{
controller = [[MyViewController alloc] initWithPageNumber:page];
[viewControllers replaceObjectAtIndex:page withObject:controller];
[controller release];
}
if (controller.view.superview == nil)
{
CGRect frame = scrollView.frame;
frame.origin.x = frame.size.width * page;
frame.origin.y = 0;
controller.view.frame = frame;
[scrollView addSubview:controller.view];
NSDictionary *numberItem = [self.contentList objectAtIndex:page];
controller.numberTitle.text = [numberItem valueForKey:NameKey];
}
}
and this is the MyViewController header:
#import <UIKit/UIKit.h>
@interface MyViewController : UIViewController
{
UILabel *pageNumberLabel;
int pageNumber;
UITextView *numberTitle;
UIImageView *numberImage;
}
@property (nonatomic, retain) IBOutlet UILabel *pageNumberLabel;
@property (nonatomic, retain) IBOutlet UITextView *numberTitle;
@property (nonatomic, retain) IBOutlet UIImageView *numberImage;
- (id)initWithPageNumber:(int)page;
@end
Check the frame of the UITextView. It’s possible if you just swapped UITextView with UILabel that the frame is not large enough. Change the frame to have a larger height. Also, set the background color to a bright color so you know can see how large it is on the screen.