Thursday, December 19, 2013

After Add subView subView not display nor wrong, solving

I used to jump to another view
navigationController from a view
navigationController code:
 - (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath 
{
_detailController = [[WBDetailContentController alloc] init];
[Self.navigationController pushViewController: _detailController animated: YES];

[_detailController Release];
}


After the jump viewDidLoad function code:
 - (void) viewDidLoad 
{
[Super viewDidLoad];
self.title = @ "test";

UIView * v = [[[UIView alloc] initWithFrame: [[UIScreen mainScreen] applicationFrame]] autorelease];
/ / UIView * v2 = [[[UIView alloc] initWithFrame: CGRectMake (1, 1, 10, 10)] autorelease];

self.view = v;
self.view.autoresizesSubviews = YES;
[V release];

_buttonForword = [[UIButton alloc] initWithFrame: CGRectMake (40, 150, 20, 10)];
_buttonComment = [[UIButton alloc] initWithFrame: CGRectMake (70, 150, 20, 10)];
_buttonMore = [[UIButton alloc] initWithFrame: CGRectMake (100, 150, 20, 10)];

_buttonMore.titleLabel.text = @ "More";
_buttonComment.titleLabel.text = @ "Comment";
_buttonForword.titleLabel.text = @ "Forword";

[Self.navigationController.view addSubview: _buttonForword];

[Self.view addSubview: _buttonComment];
[Self.view addSubview: _buttonForword];
[Self.view addSubview: _buttonMore];

[_buttonForword Release];
[_buttonComment Release];
[_buttonMore Release];
}


Not one button appears after the jump. Solving!

Thank you! ! !
Reply:
self.view = v;
To [self.view addSubview: v];

Other buttons on
added v[V addSubview: _buttonComment];
...

In addition the following sentence is useless, the same button can not add two view in
[Self.navigationController.view addSubview: _buttonForword];
Reply:
Definitely ......

Displayed, but you can not see it.
_buttonMore.titleLabel.text = @ "More";

The wording is wrong.

UIButton image and title are set to keep the state corresponding to see documentation to know.

Button to change the background image look out on the show ......

No comments:

Post a Comment