Mahesh Babu
Mahesh Babu

Reputation: 3433

How to display text in subview by button click?

Hi I am new to iPhone.

What I need is, have to display some text as help for my application. For that I create a button while clicking that button text must be displayed.

How can I do this?

Please post some code. Thank you.

Upvotes: 0

Views: 529

Answers (2)

Sivanathan
Sivanathan

Reputation: 1213

Inside your button click event,

for example.

-(IBAction) showTextView:(id)sender{

yourSubViewController * subView = [[yourSubViewController alloc]    initWithNibName:@"yourSubViewController" bundle:nil];

[self.navigationController pushViewController:subView animated:YES];

}

and inside yourSubViewController viewDidLoad method,

UITextView * textView = [[UITextView alloc] initWithFrame:CGRectMake(10, 10, 200, 200)];

textView.text = @"display your info text";

[self.view addSubview:textView];

before you must declare UITextViewDelegate in yourSubViewController.h

Upvotes: 2

priyanka
priyanka

Reputation: 2076

on button click event load new UIviewController.

add uitextview in it and load your help text in that textview

Upvotes: 0

Related Questions