Monday, December 23, 2013

iphone how to write code to trigger control navigation buttons

I know that to build a normal button can be written
UIButton * btn1 = [UIButton buttonWithType: 102];
btn1.frame = CGRectMake (160.0, 250.0, 50.0, 20.0);
[Btn1 setTitle: @ \ "view \" forState: UIControlStateNormal];
[Btn1 addTarget: self action: @ selector (loadData) forControlEvents: UIControlEventTouchUpInside];
[Self.view addSubview: btn1];


I think to build a button on the navigation bar, check the Internet is so writtenUIBarButtonItem * addButton = [[[UIBarButtonItem alloc] initWithTitle: @ \ "new \" style: UIBarButtonItemStyleBordered target: self action: @ selector (loadData :)] autorelease];

self.navigationItem.rightBarButtonItem = addButton;
After running can be displayed, but a click on an exception, is not the navigation bar buttons should also be written on like this forControlEvents ordinary button: UIControlEventTouchUpInside something like this, or are there any other reasons.
Hope advise, thank you very much.
Reply:
@ \ "New \" What ah?

View loadData: function
Wood has a relationship with the button
Reply:
@ \ "New \" is sticking up out of the garbage.
LoadData the push is a little problem, thank you anyway.

No comments:

Post a Comment