切换视图iphone - 切换到空视图
问题描述:
我有一个3视图控制器 - 注册,登录,配置文件 和我有一个UISegmentedControl,我可以切换视图从注册主要和从登录到主。 ,但是当我在注册视图中的示例id喜欢在完成注册后将用户切换到配置文件视图。切换视图iphone - 切换到空视图
和这里的代码..
-(IBAction) switchView :(id)sender{
switch (segControl.selectedSegmentIndex) {
case 0:
{
HangmanViewController * main =[[HangmanViewController alloc]initWithNibName:nil bundle:nil];
main.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:main animated:YES];
[main release];
}
break;
case 1:
break;
case 2:
{
Profile *profile2 = [[Profile alloc]initWithNibName:nil bundle:nil];
[self presentModalViewController:profile2 animated:YES];
[profile2 release];
}break;
default:
break;
}
}
和我已经进口Profile类的.h文件.. 有啥错了! !
谢谢。
答
我不明白你的问题完全希望这会帮助你。
- (IBAction)SegmentControll:(id)sender {
if (SegmentControll.selectedSegmentIndex==0) {
//your main view
}
if (SegmentControll.selectedSegmentIndex==1) {
//your Profile view
}
}
答
是否只有在成功完成注册/登录后才能将用户切换到配置文件视图否则显示警报?
,那么你可以试试这个:在.h文件中
NSString *count;
在.m文件
@Synthesize count;
在您的viewDidLoad
[email protected]"1";
//所以这里count的默认值是1
//后成功完成注册/登录化妆数= 2
[email protected]"2";
在你SegmentControl行动使这种状况:
- (IBAction)SegmentControll:(id)sender
{
if (SegmentControll.selectedSegmentIndex==0)
{
if (count isEqualToString:@"2") {
//your main view
}
else
// alert for login/Register
}
if (SegmentControll.selectedSegmentIndex==1) {
//your Profile view
}
if (SegmentControll.selectedSegmentIndex==2) {
//your Register view
}
}