Switching method between iOS UI, using Prepareforsegue and not

Source: Internet
Author: User

1, use Prepareforsegue:
-(void) Prepareforsegue: (Uistoryboardsegue *) Segue sender: (ID) sender{    * Detailcontroller =Segue.destinationviewcontroller;     *bug = [self.bugs objectAtIndex:self.tableView.indexPathForSelectedRow.row];     = bug;}
2, use Prepareforsegue:
If you want to programmatically invoke a push segue, you give the Segue a "storyboard id" in Interface Builder and then yo U can:
[Self performseguewithidentifier:"pushtomyvc" sender:self];
3, without Prepareforsegue:
Alternatively, if you don ' t want to perform the segue, you can instantiate the destination view controller and then manual Ly push to that view controller. All your need to do are to make sure, the destination view controller have its own ' storyboard id ' in Interface Builder, Then you can:
Uiviewcontroller *controller = [Self.storyboard instantiateviewcontrollerwithidentifier:@ "  Destinationcontroller"]; [Self.navigationcontroller Pushviewcontroller:controller Animated:yes];
pushViewControllerabove). If you really meant to "present a modal View controller" and then the second line is:
[Self Presentviewcontroller:controller animated:yes completion:nil];
 prepareForSegue have prepareForSegue If you want to pass information to the destination view controller. Otherwise it is not needed.
prepareForSegueIs isn't applicable in that environment. If you were using NIB, it would is as follows:
Secondviewcontroller *controller = [[Secondviewcontroller alloc] Initwithnibname:@ "  Secondviewcontroller"Bundle:nil"  ; [Self.navigationcontroller Pushviewcontroller:controller Animated:yes];

Switching methods between iOS UI, using Prepareforsegue and not

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.