IOS Click Tabbaritem for Login to judge

Source: Internet
Author: User
We sometimes click on the Tabbaritem, it is necessary to login to judge, then how do we judge it, like clicking on a shopping cart, we need users to determine how to judge the login we have to use the Tabbarcontroller in a protocol method such as:

#pragma mark determines whether to log in if not logged in to jump to the login page

-(BOOL) Tabbarcontroller: (Uitabbarcontroller *) Tabbarcontroller Shouldselectviewcontroller: (UIViewController *) viewcontroller{//method to perform each click

Make a decision when clicking on the cart Tabbaritem

Nsuserdefaults *userdefault =nsuserdefault;

nsstring* str = [userdefaultvalueforkey:@ "Loginstatu"];

if ([viewcontroller.tabbaritem.titleisequaltostring:@ "Shopping Cart"]) {//Judge click on the title of the Tabbaritem is not a shopping cart, if it is continued to execute

if ([strisequaltostring:@ "Notloggedin"]| | Str==nil) {////When login to store an identity, to determine whether logged in, do not login to execute the following code into the login page

[Selfpresentviewcontroller:[[loginviewcontrolleralloc]init]animated:yescompletion:nil];

Returnno;

}else{//Enter the shopping cart directly after login

Returnyes;

}

}

return YES;

}

Related Article

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.