Word-Wrap UITextView

Ok, I need to make UITextView Autowordwrap for an iPhone app

I'm not using IB so is there a way to do this is code?

Thanks in advance.

Macbook Pro late 1008, Mac OS X (10.5.7), For iPhone

Posted on May 28, 2009 2:34 PM

Reply
11 replies

May 28, 2009 3:50 PM in response to Duykur

I'm not sure if you're asking how to make an instance of UITextView in code, or how to use code to turn on word wrap. Word wrap is the default, and atm I don't know any way to turn it off. So I'll assume you just want to create and display a text view control:

@interface MyViewController : UIViewController {
UITextView *myTextView;
}
@property (nonatomic, retain) UITextView *myTextView;
@end
#import "MyViewController.h"
@implementation MyViewController
@synthesize myTextView;
- (void)viewDidLoad {
[super viewDidLoad];
CGRect frame = CGRectMake(20, 20, 280, 200);
UITextView *aTextView = [[UITextView alloc] initWithFrame:frame];
self.myTextView = aTextView;
[aTextView release];
[self.view addSubview:myTextView];
}
- (void)dealloc {
[myTextView release];
[super dealloc];
}
@end

Jun 1, 2009 5:57 PM in response to K T

\n also doesn't work.

My code looks like this

self.myArray= [NSArray arrayWithObjects:
@"I don’t have pet peeves — I have major psychotic hatreds! - George Carlin",
@"Think of how stupid the average person is, \n and realize half of them are stupider than that. - George Carlin",
@"Swimming is not a sport.\n Swimming is a way to keep from drowning. That’s just common sense! - George Carlin", nil];

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Word-Wrap UITextView

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.