Reputation: 20068
My view controller contains an UIImageView and a UITextView below. This is my code:
#import <UIKit/UIKit.h>
@interface DescriptionViewController : UIViewController
@property (nonatomic, strong) IBOutlet UIImageView *descriptionImage;
@property (nonatomic, strong) IBOutlet UITextView *descriptionText;
@property (nonatomic, strong) NSString *text;
@property (nonatomic, strong) NSString *image;
@end
@interface DescriptionViewController ()
@end
@implementation DescriptionViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.descriptionText = [[UITextView alloc] init];
self.descriptionImage.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:self.image]]];
self.descriptionText.text = self.text;
NSLog(@"%@", self.descriptionText.text);
}
@end
My code doesn't show up in textview, but I can print it using NSLog.
What could be the problem ?
Upvotes: 1
Views: 148
Reputation: 16526
You're initializing a new UITextView
here.-
self.descriptionText = [[UITextView alloc] init];
This way, you get a new UITextView
not linked with the main view. Remove that line and make sure descriptionText
is properly linked in your xib
or storyboard
.
However, if your intention was actually programmatically creating a new UITextView
from scratch, then you'll also have to programmatically add it to your main view.
Upvotes: 4