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;
}